Skip to content

Commit 292e26f

Browse files
committed
3 cf problems + 1 usaco
1 parent 89b9d24 commit 292e26f

File tree

6 files changed

+174
-15
lines changed

6 files changed

+174
-15
lines changed

codeforces/1816A.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @file 1816A.cpp
3+
* @author Naowal Rahman
4+
* @date 2023-04-09 10:57
5+
*/
6+
7+
#include <bits/stdc++.h>
8+
using namespace std;
9+
#define all(x) x.begin(), x.end()
10+
#define FOR(i, s, e) for(int i = s; i < e; i++)
11+
#define FORE(i, s, e) for(int i = s; i <= e; i++)
12+
typedef long long ll;
13+
typedef vector<int> vi;
14+
15+
inline void dbg() {
16+
#ifndef ONLINE_JUDGE
17+
freopen("../input.txt", "r", stdin);
18+
freopen("../output.txt", "w", stdout);
19+
#endif //
20+
}
21+
22+
int main() {
23+
ios::sync_with_stdio(false);
24+
cin.tie(0);
25+
dbg();
26+
27+
int t, a, b, mx, mn; cin >> t;
28+
while(t--) {
29+
cin >> a >> b;
30+
cout << 2 << "\n" << 1 << " " << b-1
31+
<< "\n" << a << " " << b << "\n";
32+
}
33+
34+
return 0;
35+
}

codeforces/1816B.cpp

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* @file 1816B.cpp
3+
* @author Naowal Rahman
4+
* @date 2023-04-09 11:39
5+
*/
6+
7+
#include <bits/stdc++.h>
8+
using namespace std;
9+
#define all(x) x.begin(), x.end()
10+
#define FOR(i, s, e) for(int i = s; i < e; i++)
11+
#define FORE(i, s, e) for(int i = s; i <= e; i++)
12+
typedef long long ll;
13+
typedef vector<int> vi;
14+
15+
inline void dbg() {
16+
#ifndef ONLINE_JUDGE
17+
freopen("../input.txt", "r", stdin);
18+
freopen("../output.txt", "w", stdout);
19+
#endif //
20+
}
21+
22+
int main() {
23+
ios::sync_with_stdio(false);
24+
cin.tie(0);
25+
dbg();
26+
27+
int t, n; cin >> t;
28+
while(t--) {
29+
cin >> n;
30+
deque<int> nums;
31+
FORE(i, 1, 2*n) nums.push_back(i);
32+
33+
vector<vi> grid(2, vi(n));
34+
35+
grid[0][0] = nums.back();
36+
bool alt = true;
37+
nums.pop_back();
38+
FOR(i, 0, n-1) {
39+
if(alt) {
40+
grid[1][i] = nums.front();
41+
nums.pop_front();
42+
grid[0][i+1] = nums.front();
43+
nums.pop_front();
44+
}
45+
else {
46+
grid[1][i] = nums.back();
47+
nums.pop_back();
48+
grid[0][i+1] = nums.back();
49+
nums.pop_back();
50+
}
51+
alt = !alt;
52+
}
53+
54+
grid[1][n-1] = nums.back();
55+
swap(grid[1][1], grid[1][n-1]);
56+
57+
for(vi line : grid) {
58+
for(int num : line) cout << num << " ";
59+
cout << "\n";
60+
}
61+
62+
}
63+
64+
return 0;
65+
}

codeforces/1816C.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @file 1816C.cpp
3+
* @author Naowal Rahman
4+
* @date 2023-04-09 12:47
5+
*/
6+
7+
#include <bits/stdc++.h>
8+
using namespace std;
9+
#define all(x) x.begin(), x.end()
10+
#define FOR(i, s, e) for(int i = s; i < e; i++)
11+
#define FORE(i, s, e) for(int i = s; i <= e; i++)
12+
typedef long long ll;
13+
typedef vector<int> vi;
14+
15+
inline void dbg() {
16+
#ifndef ONLINE_JUDGE
17+
freopen("../input.txt", "r", stdin);
18+
freopen("../output.txt", "w", stdout);
19+
#endif //
20+
}
21+
22+
int main() {
23+
ios::sync_with_stdio(false);
24+
cin.tie(0);
25+
dbg();
26+
27+
int t, n; cin >> t;
28+
while(t--) {
29+
cin >> n;
30+
vi arr(n);
31+
for(auto&x:arr) cin >> x;
32+
}
33+
34+
return 0;
35+
}

input.txt

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
4
21
3
3-
10 20 15
4-
9 8 6
5-
1
6-
5
7-
7
2+
2
83
4
9-
13 8 5 4
10-
3 4 2 1
11-
3
12-
1000000000 1000000000 1000000000
13-
1 1 1000000000
4+
6

output.txt

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
9 9 12
2-
5
3-
3 8 6 4
4-
1 2 2999999997
1+
4 2
2+
1 3
3+
8 2 6 4
4+
1 5 3 7
5+
12 2 10 4 8 6
6+
1 7 3 9 5 11
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main() {
5+
ifstream cin("whatbase.in");
6+
ofstream cout("whatbase.out");
7+
8+
auto toBase10 = [](vector<int>& x, int b) {
9+
return x[0] + x[1] * b + x[2] * b * b;
10+
};
11+
12+
int k, nx, ny; cin >> k;
13+
while(k--) {
14+
cin >> nx >> ny;
15+
vector<int> xd = {nx%10, (nx/10)%10, (nx/100)%10};
16+
vector<int> yd = {ny%10, (ny/10)%10, (ny/100)%10};
17+
18+
int xb = 10, yb = 10;
19+
while(xb < 15000 && yb < 15000) {
20+
int xe = toBase10(xd, xb), ye = toBase10(yd, yb);
21+
if(xe == ye) {
22+
cout << xb << " " << yb << "\n";
23+
break;
24+
}
25+
else if(xe < ye) ++xb;
26+
else ++yb;
27+
}
28+
}
29+
30+
return 0;
31+
}

0 commit comments

Comments
 (0)