The document discusses bitmasking techniques. It begins with an introduction to bitmasking, explaining how it can efficiently represent sets and states using bits. It then provides examples of how to represent a subset, sliding puzzle state, and set using bits. It also suggests some problems from BOJ that can be solved using bitmasking with operations like BFS. It moves on to discuss cumulative sums and maximum subarray sum problems, providing algorithms to solve them in linear time using prefix sums and dynamic programming respectively.
This Presentation Elliptical Curve Cryptography give a brief explain about this topic, it will use to enrich your knowledge on this topic. Use this ppt for your reference purpose and if you have any queries you'll ask questions.
Elliptic Curve Cryptography and Zero Knowledge ProofArunanand Ta
Elliptic Curve Cryptography and Zero Knowledge Proof
Presentation by Nimish Joseph, at College of Engineering Cherthala, Kerala, India, during Faculty Development Program, on 06-Nov-2013
Gives a basic idea of Finite field theory and its uses in Elliptic cure cryptography. ECDLP and Diffie Helman key exchange and Elgamal Encryption with ECC.
This Presentation Elliptical Curve Cryptography give a brief explain about this topic, it will use to enrich your knowledge on this topic. Use this ppt for your reference purpose and if you have any queries you'll ask questions.
Elliptic Curve Cryptography and Zero Knowledge ProofArunanand Ta
Elliptic Curve Cryptography and Zero Knowledge Proof
Presentation by Nimish Joseph, at College of Engineering Cherthala, Kerala, India, during Faculty Development Program, on 06-Nov-2013
Gives a basic idea of Finite field theory and its uses in Elliptic cure cryptography. ECDLP and Diffie Helman key exchange and Elgamal Encryption with ECC.
The following slides explains about elliptic curves, their interpretation over Gallois finite fields, algorithms that reduces arithmetic computational requirements and primarly applications of the ECC.
Elliptic Curve Cryptography for those who are afraid of mathsMartijn Grooten
A low level introduction into elliptic curve cryptography, as presented at BSides San Francisco 2016.
NB don't be put off by the 100 slides; every transition is on its own slide.
This presentation contains the contents pertaining to the undergraduate course on Cryptography and Network Security (UITC203) at Sri Ramakrishna Institute of Technology. This covers the Elliptic Curve Cryptography and the basis of elliptic curve arithmetics.
Mathematics (from Greek μάθημα máthēma, “knowledge, study, learning”) is the study of topics such as quantity (numbers), structure, space, and change. There is a range of views among mathematicians and philosophers as to the exact scope and definition of mathematics
Error control codes are necessary for transmission and storage of large volumes of date sensitive to errors. BCH codes and Reed Solomon codes are the most important class of multiple error correcting codes for binary and non-binary channels respectively. Peterson and later Berlekamp and Massey discovered powerful algorithms which became viable with the help of new digital technology. Use of Galois fields gave a structured approach to designing of these codes. This presentation deals with above in a very structured and systematic manner.
Bch and reed solomon codes generation in frequency domainMadhumita Tamhane
Digital signal processing is permeated with application of Fourier Transforms. When time variable is continuous, study of real-valued or complex valued signals rely heavily on Fourier transforms. Fourier Transforms also exist on the vector space of n-tuples over the Galois field GF(q) for many values of n, i.e. code-words. Cyclic codes can be defined as codes whose code-words have certain specific spectral components equal to zero. Conjugacy constraints provide an analogous condition for a finite field. BCH and Reed Solomon codes can be easily generated in frequency domain based on conjugacy constraints.
Data Security Using Elliptic Curve CryptographyIJCERT
Cryptography technique is used to provide data security. In existing cryptography technique the key generation takes place randomly. Key generation require shared key. If shared key is access by unauthorized user then security becomes disoriented. Hence existing problems are alleviated to give more security to data. In proposed system a algorithm called as Elliptic Curve Cryptography is used. The ECC generates the key by using the point on the curve. The ECC is used for generating the key by using point on the curve and encryption and decryption operation takes place through curve. In the proposed system the encryption and key generation process takes place rapidly.
The following slides explains about elliptic curves, their interpretation over Gallois finite fields, algorithms that reduces arithmetic computational requirements and primarly applications of the ECC.
Elliptic Curve Cryptography for those who are afraid of mathsMartijn Grooten
A low level introduction into elliptic curve cryptography, as presented at BSides San Francisco 2016.
NB don't be put off by the 100 slides; every transition is on its own slide.
This presentation contains the contents pertaining to the undergraduate course on Cryptography and Network Security (UITC203) at Sri Ramakrishna Institute of Technology. This covers the Elliptic Curve Cryptography and the basis of elliptic curve arithmetics.
Mathematics (from Greek μάθημα máthēma, “knowledge, study, learning”) is the study of topics such as quantity (numbers), structure, space, and change. There is a range of views among mathematicians and philosophers as to the exact scope and definition of mathematics
Error control codes are necessary for transmission and storage of large volumes of date sensitive to errors. BCH codes and Reed Solomon codes are the most important class of multiple error correcting codes for binary and non-binary channels respectively. Peterson and later Berlekamp and Massey discovered powerful algorithms which became viable with the help of new digital technology. Use of Galois fields gave a structured approach to designing of these codes. This presentation deals with above in a very structured and systematic manner.
Bch and reed solomon codes generation in frequency domainMadhumita Tamhane
Digital signal processing is permeated with application of Fourier Transforms. When time variable is continuous, study of real-valued or complex valued signals rely heavily on Fourier transforms. Fourier Transforms also exist on the vector space of n-tuples over the Galois field GF(q) for many values of n, i.e. code-words. Cyclic codes can be defined as codes whose code-words have certain specific spectral components equal to zero. Conjugacy constraints provide an analogous condition for a finite field. BCH and Reed Solomon codes can be easily generated in frequency domain based on conjugacy constraints.
Data Security Using Elliptic Curve CryptographyIJCERT
Cryptography technique is used to provide data security. In existing cryptography technique the key generation takes place randomly. Key generation require shared key. If shared key is access by unauthorized user then security becomes disoriented. Hence existing problems are alleviated to give more security to data. In proposed system a algorithm called as Elliptic Curve Cryptography is used. The ECC generates the key by using the point on the curve. The ECC is used for generating the key by using point on the curve and encryption and decryption operation takes place through curve. In the proposed system the encryption and key generation process takes place rapidly.
There are two types of ciphers - Block and Stream. Block is used to .docxrelaine1
There are two types of ciphers - Block and Stream. Block is used to encrypt a block of bits at one time. Stream cipher is used to encrypt one bit at a time.
Modes of CiphersUnderstanding Modes
Electronic Code Book (ECB) Mode
This mode is a most straightforward way of processing a series of sequentially listed message blocks.
Operation
The user takes the first block of plaintext and encrypts it with the key to produce the first block of ciphertext.
He then takes the second block of plaintext and follows the same process with same key and so on so forth.
The ECB mode is deterministic, that is, if plaintext block P1, P2,…, Pm are encrypted twice under the same key, the output ciphertext blocks will be the same
Cipher Block Chaining (CBC) Mode
CBC mode of operation provides message dependence for generating ciphertext and makes the system non-deterministic.
Operation
The operation of CBC mode is depicted in the following illustration. The steps are as follows −
Load the n-bit Initialization Vector (IV) in the top register.
XOR the n-bit plaintext block with data value in top register.
Encrypt the result of XOR operation with underlying block cipher with key K.
Feed ciphertext block into top register and continue the operation till all plaintext blocks are processed.
For decryption, IV data is XORed with first ciphertext block decrypted. The first ciphertext block is also fed into to register replacing IV for decrypting next ciphertext block.
Output Feedback (OFB) Mode
It involves feeding the successive output blocks from the underlying block cipher back to it. These feedback blocks provide string of bits to feed the encryption algorithm which act as the key-stream generator as in case of CFB mode.
The key stream generated is XOR-ed with the plaintext blocks. The OFB mode requires an IV as the initial random n-bit input block. The IV need not be secret.
Counter (CTR) Mode
It can be considered as a counter-based version of CFB mode without the feedback. In this mode, both the sender and receiver need to access to a reliable counter, which computes a new shared value each time a ciphertext block is exchanged. This shared counter is not necessarily a secret value, but challenge is that both sides must keep the counter synchronized.
Operation
Both encryption and decryption in CTR mode are depicted in the following illustration. Steps in operation are −
Load the initial counter value in the top register is the same for both the sender and the receiver. It plays the same role as the IV in CFB (and CBC) mode.
Encrypt the contents of the counter with the key and place the result in the bottom register.
Take the first plaintext block P1 and XOR this to the contents of the bottom register. The result of this is C1. Send C1 to the receiver and update the counter. The counter update replaces the ciphertext feedback in CFB mode.
Continue in this manner until the last plaintext block has been encrypted.
The decryption is.
[This sheet must be completed and attached to the last page of.docxhanneloremccaffery
[This sheet must be completed and attached to the last page of your homework]
ISE 421
Operations Research II
Term 161
Homework #1
Student Name ID# Signature
Homework Guidelines
To receive full credit, you should make sure you follow the following guidelines.
Homework Presentation:
• Every main problem should be answered on a different page.
• You should submit the solutions for the first two problems only.
• All pages of your homework should be in chronological order.
• Your name, and the homework number should be clearly indicated.
Modeling Questions:
• Clearly define all the variables in one group. Then clearly define all the parameters in another group. Then display
the final model in the standard style (Objective, Constraints, Restriction on Domain). You can use ABCD, and
EVER OLD CARD mnemonic if desired.
ISE-421 HW-1
Problem #1
Suppose that the decision variables of a mathematical programming model are defined as:
xi,j,t := acers of land plot i allocated to crop j in year t
Ct := the funds in SAR donated by the governament at the begining of year t
Rj,t := the revenue generated from crop j in $ at the end of year t
where i = 1, . . . , 47; j = 1, . . . , 9; t = 1, . . . , 10.
Use summation (
∑
) and enumeration (∀) indexed notation to write expressions for each of
the following systems of constraints in terms of these decision variables, and determine how many
constraints belong to each system. You need to define additional variables to model the following
constraints. Assume $1 = 3.75SAR. In addition assume appropriate information wherever neces-
sary.
(a) The acres allocated in each plot i cannot exceed the available acreage (call it Ai) in any year.
(b) At least 1000 total acres must be devoted to corn (corp j = 4) in each year.
(c) At least one-third of the total acreage planted over 10 years must be in soybeans (corp j = 2).
(d) Either rice (corp j = 9) or wheat (corp j = 8) should be planted in a given year.
(e) Grapes (corp j = 7) should be planted in a year, when the current funds from the government
and the total revenue from the previous year is greater than or equal to 38000 SAR.
(f) In the odd years (t = 1, 3, . . . , 9) land plot 32 is unusable.
(g) On the same land plot, there should be at least a two years of difference between corn and rice
crops plantation.
(h) If soybeans are planted in a land plot, then no other crops should be planted on the same land
plot.
(i) Every plot must be used for planting in a given year.
(j) In every year, there should be at least 7 different crops.
1
ISE-421 HW-1
Problem #2
Consider the following IP problem.
maximize :
14 ∗ x1 + 22 ∗ x2 + 12 ∗ x3 + 10 ∗ x4
subject to :
50 ∗ x1 + 70 ∗ x2 + 40 ∗ x3 + 30 ∗ x4 ≤ 100
10 ∗ x1 + 60 ∗ x2 + 50 ∗ x3 + 60 ∗ x4 ≤ 80
6 ∗ x1 + 1 ∗ x2 + 3 ∗ x3 + 7 ∗ x4 ≤ 9
xi ∈ {0, 1} ∀ i = 1, . . . , 4
(a) Write the LP relaxation of the above model.
(b) Get the optimal objective function value of the LP relaxation from Tabl.
Unix and Shell Programming,
Q P Code: 60305.
Additional Mathematics I
Q P Code: 60306
Computer Organization and Architecture
Q P Code: 62303
Data Structures Using C
Q P Code: 60303
Discrete Mathematical Structures
Q P Code: 60304
Engineering Mathematics - III
Q P Code: 60301
Soft Skill Development
Q P Code: 60307
Unix and Shell Programming,
Q P Code: 60305.
Additional Mathematics I
Q P Code: 60306
Computer Organization and Architecture
Q P Code: 62303
Data Structures Using C
Q P Code: 60303
Discrete Mathematical Structures
Q P Code: 60304
Engineering Mathematics - III
Q P Code: 60301
Soft Skill Development
Q P Code: 60307
Quality defects in TMT Bars, Possible causes and Potential Solutions.PrashantGoswami42
Maintaining high-quality standards in the production of TMT bars is crucial for ensuring structural integrity in construction. Addressing common defects through careful monitoring, standardized processes, and advanced technology can significantly improve the quality of TMT bars. Continuous training and adherence to quality control measures will also play a pivotal role in minimizing these defects.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfKamal Acharya
The College Bus Management system is completely developed by Visual Basic .NET Version. The application is connect with most secured database language MS SQL Server. The application is develop by using best combination of front-end and back-end languages. The application is totally design like flat user interface. This flat user interface is more attractive user interface in 2017. The application is gives more important to the system functionality. The application is to manage the student’s details, driver’s details, bus details, bus route details, bus fees details and more. The application has only one unit for admin. The admin can manage the entire application. The admin can login into the application by using username and password of the admin. The application is develop for big and small colleges. It is more user friendly for non-computer person. Even they can easily learn how to manage the application within hours. The application is more secure by the admin. The system will give an effective output for the VB.Net and SQL Server given as input to the system. The compiled java program given as input to the system, after scanning the program will generate different reports. The application generates the report for users. The admin can view and download the report of the data. The application deliver the excel format reports. Because, excel formatted reports is very easy to understand the income and expense of the college bus. This application is mainly develop for windows operating system users. In 2017, 73% of people enterprises are using windows operating system. So the application will easily install for all the windows operating system users. The application-developed size is very low. The application consumes very low space in disk. Therefore, the user can allocate very minimum local disk space for this application.
Cosmetic shop management system project report.pdfKamal Acharya
Buying new cosmetic products is difficult. It can even be scary for those who have sensitive skin and are prone to skin trouble. The information needed to alleviate this problem is on the back of each product, but it's thought to interpret those ingredient lists unless you have a background in chemistry.
Instead of buying and hoping for the best, we can use data science to help us predict which products may be good fits for us. It includes various function programs to do the above mentioned tasks.
Data file handling has been effectively used in the program.
The automated cosmetic shop management system should deal with the automation of general workflow and administration process of the shop. The main processes of the system focus on customer's request where the system is able to search the most appropriate products and deliver it to the customers. It should help the employees to quickly identify the list of cosmetic product that have reached the minimum quantity and also keep a track of expired date for each cosmetic product. It should help the employees to find the rack number in which the product is placed.It is also Faster and more efficient way.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
Event Management System Vb Net Project Report.pdfKamal Acharya
In present era, the scopes of information technology growing with a very fast .We do not see any are untouched from this industry. The scope of information technology has become wider includes: Business and industry. Household Business, Communication, Education, Entertainment, Science, Medicine, Engineering, Distance Learning, Weather Forecasting. Carrier Searching and so on.
My project named “Event Management System” is software that store and maintained all events coordinated in college. It also helpful to print related reports. My project will help to record the events coordinated by faculties with their Name, Event subject, date & details in an efficient & effective ways.
In my system we have to make a system by which a user can record all events coordinated by a particular faculty. In our proposed system some more featured are added which differs it from the existing system such as security.
About
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Technical Specifications
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
Key Features
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface
• Compatible with MAFI CCR system
• Copatiable with IDM8000 CCR
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
Application
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
2. 강의자 소개
2020 AL林 정기 스터디 2
이름 최문기
소속 서울시립대 컴퓨터과학부(16학번)
핸들 iknoom1107(BOJ) IKnoom(Codeforces) IKnoom(AtCoder)
ICPC 팀 ManManChiAnunTeam (2020 Seoul Regional 본선 진출 및 28위)
- 김정현, 최문기, 최연웅
3. 오늘 할 것
2020 AL林 정기 스터디 3
원래는 비트마스크만 발표하려고 했으나 너무 짧을 것 같아서 이것저것 내가 하고싶은거 모아서 발표하기
• 비트마스크
• 누적 합
• 최대 부분 합
• 스위핑 기법
• 투 포인터
5. 비트마스크
2020 AL林 정기 스터디 5
어떤 상태를 비트로 표현하여 저장하는 테크닉입니다.
그러면
① 연산이 빠르고
② 메모리가 적게 듭니다.
6. 활용예 ① : 집합의 표현
2020 AL林 정기 스터디 6
1부터 8까지의 수가 있습니다.
그 중에서 몇 개의 수를 선택한 부분 집합를 비트로 표현해봅시다.
8 7 6 5 4 3 2 1
7. 활용예 ① : 집합의 표현
2020 AL林 정기 스터디 7
00000000(2) = 0
8 7 6 5 4 3 2 1
8. 활용예 ① : 집합의 표현
2020 AL林 정기 스터디 8
00000001(2) = 1
8 7 6 5 4 3 2 1
9. 활용예 ① : 집합의 표현
2020 AL林 정기 스터디 9
00001001(2) = 9
8 7 6 5 4 3 2 1
10. 활용예 ① : 집합의 표현
2020 AL林 정기 스터디 10
00011001(2) = 25
8 7 6 5 4 3 2 1
11. 활용예 ① : 집합의 표현
2020 AL林 정기 스터디 11
10011001(2) = 153
8 7 6 5 4 3 2 1
12. 활용예 ① : 집합의 표현
2020 AL林 정기 스터디 12
11111111(2) = 255
8 7 6 5 4 3 2 1
13. 활용예 ① : 집합의 표현
2020 AL林 정기 스터디 13
이렇게 집합을 비트로 표현하면 C에서
int는 32비트이므로 최대 집합의 크기가 32이고
long long은 64비트이므로 최대 집합의 크기가 64입니다.
집합이 작은 경우 비트로 표현하여 저장하면 효율적입니다.
14. 활용예 ② : 슬라이딩 퍼즐
2020 AL林 정기 스터디 14
이 슬라이딩 퍼즐도 비트마스킹으로 표현이 가능합니다.
퍼즐의 상태가 8 이하의 수 9개의 순열로 표현되기 때문이지요.
15. 활용예 ② : 슬라이딩 퍼즐
2020 AL林 정기 스터디 15
왼쪽 슬라이딩 퍼즐은 “806547231”로 표현할 수 있습니다.
비트마스킹으로 줄여봅시다.
0
8 = 1000(2)
0 = 0000(2)
6 = 0110(2)
5 = 0101(2)
4 = 0100(2)
7 = 0111(2)
2 = 0010(2)
3 = 0011(2)
1 = 0001(2)
17. 활용예 ② : 슬라이딩 퍼즐
2020 AL林 정기 스터디 17
15-퍼즐(4×4퍼즐)까지는 long long으로 표현이 가능합니다.
4비트의 양의 정수 16개로 표현 가능하기 때문이지요.
꼭 이렇게 해서 풀어야하는 건 아닙니다.
저는 백준에 있는 슬라이딩 퍼즐 문제 string으로 저장해서 풀었습니다.
비트마스킹을 하면 메모리나 시간이 더 효율적이겠지요.
18. 연습문제 : BOJ 11723번 집합
2020 AL林 정기 스터디 18
비트마스킹을 활용하여 집합의 상태를 표현하는 기본 문제입니다.
<<, &, | 와 같은 비트 연산자를 활용해봅시다.
소스 코드 : http://boj.kr/656f225451174337b55f53049181168f
19. 연습문제 : BOJ 11723번 집합
2020 AL林 정기 스터디 19
if query[0] == "add":
x = int(query[1]) - 1
SET |= (1 << x)
elif query[0] == "remove":
x = int(query[1]) - 1
if SET & (1 << x):
SET -= (1 << x)
# 또는 SET &= ~(1 << x)
elif query[0] == "toggle":
x = int(query[1]) - 1
SET ^= (1 << x)
20. 연습문제 : BOJ 11723번 집합
2020 AL林 정기 스터디 20
elif query[0] == "check":
x = int(query[1]) - 1
if SET & (1 << x):
print(1)
else:
print(0)
elif query[0] == "all":
SET = (1 << 20) - 1
elif query[0] == "empty":
SET = 0
21. 연습문제
2020 AL林 정기 스터디 21
BOJ 17453 두 개의 문 : 비트가 많아지면 분할하거나 std::bitset을 씁니다.
BOJ 2098 외판원 순회 : 방문한 마을을 비트로 표현 + DP
BOJ 1194 달이 차오른다, 가자. : 가진 열쇠를 비트로 표현 + BFS
BOJ 1525 퍼즐 : 슬라이딩 퍼즐의 상태를 비트로 표현 + BFS
22. 비트마스킹 : 마무리..
2020 AL林 정기 스터디 22
- 알고리즘 문제해결 전략(종만북)을 575페이지를 보면 집합의 표현에 대한 더 자세
한 내용이 있습니다. 좋은 테크닉이 많지만 전부 알 필요는 없다고 생각됩니다.
- 비트마스킹은 보통 DP와 같이 활용되거나 상태공간을 BFS, DFS와 같은 탐색 알고
리즘을 써서 탐색할 때에도 활용됩니다. 보통 이런 경우에 상태에 어떤 값을 연관시
켜야하기 때문이지요.
28. 연습문제
2020 AL林 정기 스터디 28
BOJ 11659 구간 합 구하기 4 : 기본 문제입니다.
BOJ 11660 구간 합 구하기 5 : 차원을 늘려봅시다.
29. 누적 합 : 마무리..
2020 AL林 정기 스터디 29
- 부분합을 구하면서 배열의 값의 갱신이 일어나는 경우가 있습니다. 이런 경우에 누적
합은 갱신이 느려서 효율적으로 처리하기 위해서 세그먼트 트리나 펜윅 트리를 씁니
다.
- 이게 꼭 합(sum)이 아니어도 다른 연산에도 활용이 가능합니다. 예를 들어 Xor도
가능하겠지요.
31. 최대 부분합
2020 AL林 정기 스터디 31
이번에는 최대 부분합을 구해봅시다.
방금 누적 합을 응용하면 O(N^2)에 가능하겠지요?
prefixSum을 구해놓으면 a부터 b까지의 부분합은 O(1)에 구할 수 있고
[a, b] 구간의 수가 N(N-1)/2개이기 때문입니다.
32. 최대 부분합
2020 AL林 정기 스터디 32
하지만 최대 부분합은 O(N)에 가능합니다. 구해봅시다.
maxSum[i] : A[i]를 가장 오른쪽 끝으로 가지는 최대 부분합
i 0 1 2 3 4 5 6 7
A 3 4 -3 10 -99 5 3 -1
maxSum
33. 최대 부분합
2020 AL林 정기 스터디 33
i 0 1 2 3 4 5 6 7
A 3 4 -3 10 -99 5 3 -1
maxSum 3
i 0 1 2 3 4 5 6 7
A 3 4 -3 10 -99 5 3 -1
maxSum 3 7
34. 최대 부분합
2020 AL林 정기 스터디 34
i 0 1 2 3 4 5 6 7
A 3 4 -3 10 -99 5 3 -1
maxSum 3 7 4
i 0 1 2 3 4 5 6 7
A 3 4 -3 10 -99 5 3 -1
maxSum 3 7 4 14
35. 최대 부분합
2020 AL林 정기 스터디 35
i 0 1 2 3 4 5 6 7
A 3 4 -3 10 -99 5 3 -1
maxSum 3 7 4 14 -85
i 0 1 2 3 4 5 6 7
A 3 4 -3 10 -99 5 3 -1
maxSum 3 7 4 14 -85 5
37. 최대 부분합
2020 AL林 정기 스터디 37
maxSum[i] : A[i]를 가장 오른쪽 끝으로 가지는 최대 부분합
그럼 다음 점화식이 성립합니다.
maxSum[i] = max(maxSum[i – 1], 0) + A[i]
38. 연습문제 : BOJ 1912 연속합
2020 AL林 정기 스터디 38
소스코드 : http://boj.kr/c31fcf4a82344dbdb84de73c845c7585
maxSum = 0
for i in range(N):
maxSum = max(maxSum, 0) + A[i]
answer = max(answer, maxSum)
39. 최대 부분합 : 마무리..
2020 AL林 정기 스터디 39
- 이걸 누가 이름도 지어놨습니다. 카데인 알고리즘이라고 합니다.
40. 최대 부분합 : 마무리..
2020 AL林 정기 스터디 40
- 최대 부분합을 구하는건 O(N)에 가능하지만 이게 구간쿼리로 들어오거나 갱신이 있
으면 처음 세그트리를 구축하고 나서 분할정복으로 쿼리를 O(logN)으로 처리하는
방법이 있습니다. 이 세그먼트 트리가 상당히 더럽고 복잡하고 구현하기 어렵습니다.
2019 ICPC 본선에 나온 적이 있지요.
42. 스위핑 기법
2020 AL林 정기 스터디 42
1. 어떤 기준으로 정렬하고
2. 순서대로 훑습니다.
바로 문제를 봅시다.
43. 활용예 ① : BOJ 2170 선긋기
2020 AL林 정기 스터디 43
선을 그을 때에는 이미 선이 있는 위치에 겹쳐서 그릴 수도 있는데,
여러 번 그은 곳과 한 번 그은 곳의 차이를 구별할 수 없다고 하자.
이와 같은 식으로 선을 그었을 때, 그려진 선(들)의 총 길이를 구하는 프로그램을 작성하시오.
예제 입력
4
1 3
2 5
3 5
6 7
예제 출력
5
44. 활용예 ① : BOJ 2170 선긋기
2020 AL林 정기 스터디 44
1. 시작점 기준으로 정렬합니다.
2. 정렬한 순서대로 구간을 봅시다.
이전까지 그은 선과 이어지면 합칩니다.
그게 아니면 끊습니다.
45. 활용예 ① : BOJ 2170 선긋기
2020 AL林 정기 스터디 45
예제 입력
4
1 3
2 5
3 5
6 7
s = 1
e = 3
46. 활용예 ① : BOJ 2170 선긋기
2020 AL林 정기 스터디 46
예제 입력
4
1 3
2 5
3 5
6 7
이전까지 그은 선과 이어지면 합칩니다.
s = 1
e = 3
47. 활용예 ① : BOJ 2170 선긋기
2020 AL林 정기 스터디 47
예제 입력
4
1 3
2 5
3 5
6 7
이전까지 그은 선과 이어지면 합칩니다.
s = 1
e = 5
48. 활용예 ① : BOJ 2170 선긋기
2020 AL林 정기 스터디 48
예제 입력
4
1 3
2 5
3 5
6 7
이전까지 그은 선과 이어지면 합칩니다.
s = 1
e = 5
49. 활용예 ① : BOJ 2170 선긋기
2020 AL林 정기 스터디 49
예제 입력
4
1 3
2 5
3 5
6 7
이전까지 그은 선과 이어지면 합칩니다.
s = 1
e = 5
50. 활용예 ① : BOJ 2170 선긋기
2020 AL林 정기 스터디 50
예제 입력
4
1 3
2 5
3 5
6 7 그게 아니면 끊습니다.
s = 6
e = 7
51. 활용예 ① : BOJ 2170 선긋기
2020 AL林 정기 스터디 51
예제 입력
4
1 3
2 5
3 5
6 7 그게 아니면 끊습니다.
s = 6
e = 7
52. 활용예 ① : BOJ 2170 선긋기
2020 AL林 정기 스터디 52
# 정렬
lines.sort()
# 스위핑
s, e = lines[0]
sumLength = 0
for s_i, e_i in lines[1:]:
if e < s_i:
sumLength += e - s
s, e = s_i, e_i
else:
e = max(e, e_i)
sumLength += e - s
# 출력
print(sumLength)
소스코드 : http://boj.kr/ede76a53e51042a2b61367e289fa4186
53. 활용예 ② : BOJ 1689 겹치는 선분
2020 AL林 정기 스터디 53
1차원 좌표계 위에 선분 N개가 있다.
선분이 최대로 겹쳐있는 부분의 겹친 선분의 개수를 구해보자.
선분의 끝 점에서 겹치는 것은 겹치는 것으로 세지 않는다.
예제 입력
11
1 2
3 6
7 8
10 11
13 16
0 5
5 6
2 5
6 10
9 14
12 15
예제 출력
3
54. 활용예 ② : BOJ 1689 겹치는 선분
2020 AL林 정기 스터디 54
시작점은 +1, 끝점은 -1을 매깁시다.
55. 활용예 ② : BOJ 1689 겹치는 선분
2020 AL林 정기 스터디 55
이제 시작점, 끝점만 보면서 스위핑을 해봅시다.
시작점과 끝점은 2N개 밖에 없지요.
+1
+1
+1
+1 +1
-1
-1
-1
-1
-1
56. 활용예 ② : BOJ 1689 겹치는 선분
2020 AL林 정기 스터디 56
+1
+1
+1
+1 +1
-1
-1
-1
-1
겹치는 선분 = 1개
-1
57. 활용예 ② : BOJ 1689 겹치는 선분
2020 AL林 정기 스터디 57
+1
+1
+1
+1 +1
-1
-1
-1
-1
겹치는 선분 = 2개
-1
58. 활용예 ② : BOJ 1689 겹치는 선분
2020 AL林 정기 스터디 58
+1
+1
+1
+1 +1
-1
-1
-1
-1
겹치는 선분 = 3개
-1
59. 활용예 ② : BOJ 1689 겹치는 선분
2020 AL林 정기 스터디 59
+1
+1
+1
+1 +1
-1
-1
-1
-1
겹치는 선분 = 2개
-1
60. 활용예 ② : BOJ 1689 겹치는 선분
2020 AL林 정기 스터디 60
+1
+1
+1
+1 +1
-1
-1
-1
-1
겹치는 선분 = 3개
-1
61. 활용예 ② : BOJ 1689 겹치는 선분
2020 AL林 정기 스터디 61
+1
+1
+1
+1 +1
-1
-1
-1
-1
겹치는 선분 = 4개
-1
62. 활용예 ② : BOJ 1689 겹치는 선분
2020 AL林 정기 스터디 62
+1
+1
+1
+1 +1
-1
-1
-1
-1
겹치는 선분 = 3개
-1
63. 활용예 ② : BOJ 1689 겹치는 선분
2020 AL林 정기 스터디 63
+1
+1
+1
+1 +1
-1
-1
-1
-1
겹치는 선분 = 2개
-1
64. 활용예 ② : BOJ 1689 겹치는 선분
2020 AL林 정기 스터디 64
+1
+1
+1
+1 +1
-1
-1
-1
-1
겹치는 선분 = 1개
-1
65. 활용예 ② : BOJ 1689 겹치는 선분
2020 AL林 정기 스터디 65
+1
+1
+1
+1 +1
-1
-1
-1
-1
겹치는 선분 = 0개
-1
66. 활용예 ② : BOJ 1689 겹치는 선분
2020 AL林 정기 스터디 66
# 시작점과 끝점만 넣습니다.
points = []
for s_i, e_i in lines:
points.append((s_i, 1))
points.append((e_i, -1))
# 정렬
points.sort()
# 스위핑
lineCnt = 0
maxCnt = 0
for x, diff in points:
lineCnt += diff
maxCnt = max(maxCnt, lineCnt)
# 출력
print(maxCnt)
소스코드 : http://boj.kr/d54636fd209e451f9604ad0a5ca7663e
67. 활용예 ② : BOJ 1689 겹치는 선분
2020 AL林 정기 스터디 67
시작점과 끝점만 넣고 스위핑하는 테크닉은
이렇게 구간 쿼리를 한번에 갱신해버리거나
68. 활용예 ② : BOJ 1689 겹치는 선분
2020 AL林 정기 스터디 68
시작점과 끝점만 넣고 스위핑하는 테크닉은
이렇게 여러 직사각형의 면적합을 구할 때도 사용할 수도 있습니다.
69. 스위핑 기법 : 마무리..
2020 AL林 정기 스터디 69
- 스위핑으로 해결할 수 있는 문제는 정말 많고 이게 무슨 알고리즘이 아니라 그냥 정
렬하고 훑는거라 어디에 가져다가 붙여도 틀렸다고 하기 어렵고 그렇습니다..
- 다만 스위핑 기법으로 해결할 수 있는 어려운 문제 중에 풀이 방법이 유명한 문제들
이 몇 개 있습니다. 대표적으로 가장 가까운 두 점(스위핑 + BST), 2차 평면에서의
직사각형의 면적(스위핑 + 세그먼트 트리) 등등
- 선분을 시계방향으로 돌리면서 훑는 스위핑 기법도 있습니다. 기하 관련 알고리즘에
서 씁니다. ex) 컨벡스 헐
70. 스위핑 기법 : 마무리..
2020 AL林 정기 스터디 70
스위핑 관련 tutorials & 문제
- https://www.topcoder.com/community/competitive-programming/tutorials/line-sweep-algorithms/
- https://codeforces.com/blog/entry/20377
- https://m.blog.naver.com/kks227/220907708368
72. 투 포인터
2020 AL林 정기 스터디 72
배열의 원소를 가리키는 2개의 포인터를 이용하는 기법을 말합니다.
이거도 바로 예시를 봅시다.
73. 활용예 ① : BOJ 2003 수들의 합 2
2020 AL林 정기 스터디 73
수열 A의 부분합이 M이 되는 경우의 수를 구하는 프로그램을 작성하시오.
수열 A의 각 원소는 자연수이다.
예) M = 5, A = {1, 2, 3, 4, 2, 5, 3, 1, 1, 2}이면 답은 3
예제 입력
10 5
1 2 3 4 2 5 3 1 1 2
예제 출력
3
74. 활용예 ① : BOJ 2003 수들의 합 2
2020 AL林 정기 스터디 74
부분합을 모두 탐색하는 건 앞에서 O(N^2)이었지요.
투 포인터를 활용하여 O(N)에 문제를 해결해봅시다.
먼저 배열의 인덱스를 가리키는 변수인 포인터 l, r을 선언합시다.
l = 0, r = 0입니다.
75. 활용예 ① : BOJ 2003 수들의 합 2
2020 AL林 정기 스터디 75
이제 r을 1씩 증가시킬 때마다 l을 관리해봅시다. lrSum은 l부터 r - 1까지의 합입니다.
1 2 3 4 2 5 3 1 1 2 M = 5
l
r
lrSum = 0
76. 활용예 ① : BOJ 2003 수들의 합 2
2020 AL林 정기 스터디 76
1 2 3 4 2 5 3 1 1 2 M = 5
l
r
lrSum = 1
r = 1
77. 활용예 ① : BOJ 2003 수들의 합 2
2020 AL林 정기 스터디 77
r = 2
1 2 3 4 2 5 3 1 1 2 M = 5
l
r
lrSum = 3
78. 활용예 ① : BOJ 2003 수들의 합 2
2020 AL林 정기 스터디 78
r = 3
이때, lrSum >= M이고 l을 놔두고 r을 아무리 증가시켜도 lrSum > M이겠지요.
이제 l을 관리합시다.
1 2 3 4 2 5 3 1 1 2 M = 5
l
r
lrSum = 6
79. 활용예 ① : BOJ 2003 수들의 합 2
2020 AL林 정기 스터디 79
r = 3
lrSum = M 인 구간을 찾았습니다. (l = 1, r = 3)
그리고 또 l을 관리합시다.
1 2 3 4 2 5 3 1 1 2 M = 5
l
r
lrSum = 5
80. 활용예 ① : BOJ 2003 수들의 합 2
2020 AL林 정기 스터디 80
r = 3
lrSum < M이므로 다시 r을 증가시킵시다.
1 2 3 4 2 5 3 1 1 2 M = 5
l
r
lrSum = 3
81. 활용예 ① : BOJ 2003 수들의 합 2
2020 AL林 정기 스터디 81
r = 4
1 2 3 4 2 5 3 1 1 2 M = 5
l
r
lrSum = 7
82. 활용예 ① : BOJ 2003 수들의 합 2
2020 AL林 정기 스터디 82
r = 4
1 2 3 4 2 5 3 1 1 2 M = 5
l
r
lrSum = 4
83. 활용예 ① : BOJ 2003 수들의 합 2
2020 AL林 정기 스터디 83
r = 5
1 2 3 4 2 5 3 1 1 2 M = 5
l
r
lrSum = 6
84. 활용예 ① : BOJ 2003 수들의 합 2
2020 AL林 정기 스터디 84
r = 5
1 2 3 4 2 5 3 1 1 2 M = 5
l
r
lrSum = 2
85. 활용예 ① : BOJ 2003 수들의 합 2
2020 AL林 정기 스터디 85
r = 6
1 2 3 4 2 5 3 1 1 2 M = 5
l
r
lrSum = 7
86. 활용예 ① : BOJ 2003 수들의 합 2
2020 AL林 정기 스터디 86
r = 6
lrSum = M인 구간을 찾았습니다. (l = 5, r = 6)
1 2 3 4 2 5 3 1 1 2 M = 5
l
r
lrSum = 5
87. 활용예 ① : BOJ 2003 수들의 합 2
2020 AL林 정기 스터디 87
(중략...) r = 9
lrSum = M인 구간을 찾았습니다. (l = 6, r = 9)
1 2 3 4 2 5 3 1 1 2 M = 5
l
r
lrSum = 5
88. 활용예 ① : BOJ 2003 수들의 합 2
2020 AL林 정기 스터디 88
answer = 0
lrSum = 0
l = 0
for r in range(1, N + 1):
lrSum += A[r - 1]
while l < r and lrSum >= M:
if lrSum == M:
answer += 1
lrSum -= A[l]
l += 1
print(answer)
소스코드 : http://boj.kr/988018727c0e440f829616886c014bdd
89. 투 포인터 : 마무리..
2020 AL林 정기 스터디 89
- 이거도 쓰이는 방법이야 다양하지만 [l, r] 구간을 관리하면서 푸는 유형이 대부분인데,
방금 연습문제에서 본 것과 같이 r을 선형으로 훑으면서 r이 증가할 때마다 l이 조건
을 만족하도록 관리하는 유형입니다.
- [l, r] 구간의 크기가 일정하게 하여 훑는 테크닉은 슬라이딩 윈도우라고 합니다.