Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a6f16cd

Browse files
committedJul 31, 2024
~7.31
1 parent d0ab568 commit a6f16cd

File tree

10 files changed

+222
-0
lines changed

10 files changed

+222
-0
lines changed
 

‎boj/gist_algomasters/31907

38.6 KB
Binary file not shown.

‎boj/gist_algomasters/31907.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main(){
6+
int key;
7+
cin >> key;
8+
for(int i = 0; i < key; i++){
9+
for(int j = 0; j < key; j++){
10+
cout << "G";
11+
}
12+
for(int k = 0; k < key; k++){
13+
cout << "...";
14+
}
15+
cout << "\n";
16+
}
17+
for(int i = 0; i < key; i++){
18+
for(int j = 0; j < key; j++){
19+
cout << ".";
20+
}
21+
for(int k = 0; k < key; k++){
22+
cout << "I";
23+
}
24+
for(int l = 0; l < key; l++){
25+
cout << ".";
26+
}
27+
for(int m = 0; m < key; m++){
28+
cout << "T";
29+
}
30+
cout << "\n";
31+
}
32+
for(int i = 0; i < key; i++){
33+
for(int j = 0; j < key; j++){
34+
cout << "..";
35+
}
36+
for(int k = 0; k < key; k++){
37+
cout << "S";
38+
}
39+
for(int l = 0; l < key; l++){
40+
cout << ".";
41+
}
42+
cout << "\n";
43+
}
44+
45+
}

‎boj/gist_algomasters/31908

163 KB
Binary file not shown.

‎boj/gist_algomasters/31908.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <iostream>
2+
#include <string>
3+
#include <unordered_map>
4+
#include <vector>
5+
#include <utility>
6+
7+
8+
9+
int main(){
10+
int numberOfStudents;
11+
std::cin >> numberOfStudents;
12+
13+
std::unordered_map<std::string, std::vector<std::string>> ringMap;
14+
std::string name, ring;
15+
16+
for(int i = 0; i < numberOfStudents; i++){
17+
std::cin >> name >> ring;
18+
if(ring != "-")
19+
ringMap[ring].push_back(name);
20+
}
21+
22+
std::vector<std::pair<std::string, std::string>> couples;
23+
24+
for(const auto& pair : ringMap){
25+
if (pair.second.size() == 2){
26+
couples.emplace_back(pair.second[0], pair.second[1]);
27+
}
28+
}
29+
30+
if(couples.empty()){
31+
std::cout << "0";
32+
} else {
33+
std::cout << couples.size() << "\n";
34+
for(const auto& couple : couples){
35+
std::cout << couple.first << " " << couple.second << "\n";
36+
}
37+
}
38+
39+
return 0;
40+
}

‎boj/gist_algomasters/31909

46.6 KB
Binary file not shown.

‎boj/gist_algomasters/31909.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include <iostream>
2+
#include <vector>
3+
4+
int main(){
5+
int numberOfCommands, deactivationKey;
6+
int arr[7] = {1, 2, 3, 4, 5, 6, 7};
7+
std::cin >> numberOfCommands;
8+
int commands;
9+
std::vector<int> powersOfTwo;
10+
11+
for(int i = 1; i <= 7; ++i){
12+
int power = 1 << i;
13+
powersOfTwo.push_back(power);
14+
}
15+
16+
for(int i = 0; i < numberOfCommands; i++){
17+
std::cin >> commands;
18+
for(int i = 0; i < powersOfTwo.size(); ++i){
19+
int a = powersOfTwo[i];
20+
int b = commands - a;
21+
22+
if(b != a){
23+
for(int j = 0; j < powersOfTwo.size(); ++j){
24+
if(powersOfTwo[j] == b){
25+
int index_a = i + 1;
26+
int index_b = j + 1;
27+
28+
std::swap(arr[index_a], arr[index_b]);
29+
break;
30+
}
31+
}
32+
}
33+
}
34+
}
35+
36+
std::cin >> deactivationKey;
37+
for(int i = 0; i < 7; i++){
38+
if(arr[i] == deactivationKey){
39+
std::cout << i+1;
40+
}
41+
}
42+
43+
return 0;
44+
}

‎boj/gist_algomasters/31910

85.3 KB
Binary file not shown.

‎boj/gist_algomasters/31910.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <iostream>
2+
#include <vector>
3+
#include <algorithm>
4+
5+
int main(){
6+
int N;
7+
std::cin >> N;
8+
std::vector<std::vector<int>> grid(N, std::vector<int>(N));
9+
for(int i = 0; i < N; i++){
10+
for(int j = 0; j < N; j++){
11+
std::cin >> grid[i][j];
12+
}
13+
}
14+
15+
std::vector<std::vector<long long>> sum(N, std::vector<long long>(N));
16+
17+
sum[0][0] = grid[0][0];
18+
19+
for(int j = 1; j < N; ++j){
20+
sum[0][j] = (sum[0][j-1] << 1) + grid[0][j];
21+
}
22+
23+
for(int i = 1; i < N; ++i){
24+
sum[i][0] = (sum[i-1][0] << 1) + grid[i][0];
25+
}
26+
27+
for(int i = 1; i < N; ++i){
28+
for(int j = 1; j < N; ++j){
29+
sum[i][j] = std::max(sum[i-1][j], sum[i][j-1]) << 1 | grid[i][j];
30+
}
31+
}
32+
33+
std::cout << sum[N-1][N-1];
34+
return 0;
35+
}

‎boj/gist_algomasters/shorter31908.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <iostream>
2+
#include <unordered_map>
3+
#include <vector>
4+
using namespace std;
5+
6+
int main()
7+
{
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(nullptr);
10+
11+
int N;
12+
cin >> N;
13+
14+
unordered_map<string, vector<string>> um;
15+
16+
for (string p, s; cin >> p >> s;) {
17+
if (s != "-")
18+
um[s].emplace_back(p);
19+
}
20+
21+
int count = 0;
22+
23+
for (const auto& p : um) {
24+
if (p.second.size() == 2)
25+
++count;
26+
}
27+
28+
cout << count << '\n';
29+
30+
if (count) {
31+
for (const auto& p : um) {
32+
if (p.second.size() == 2)
33+
cout << p.second[0] << ' ' << p.second[1] << '\n';
34+
}
35+
}
36+
}

‎boj/gist_algomasters/shorter31910.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include<stdio.h>
2+
typedef long long ll;
3+
ll d[31][31],i,j,k,n;
4+
bool a[31][31];
5+
int main(){
6+
scanf("%lld",&n);
7+
for(i=1;i<=n;++i){
8+
for(j=1;j<=n;++j){
9+
scanf("%lld",&k);
10+
a[i][j]=k;
11+
}
12+
}
13+
for(i=1;i<=n;++i){
14+
for(j=1;j<=n;++j){
15+
d[i][j]=d[i-1][j]>d[i][j-1]?d[i-1][j]:d[i][j-1];
16+
k=a[i][j];
17+
d[i][j]=(d[i][j]<<1)|k;
18+
}
19+
}
20+
printf("%lld",d[n][n]);
21+
return 0;
22+
}

0 commit comments

Comments
 (0)
Please sign in to comment.