# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
439324 |
2021-06-29T15:40:46 Z |
Sara |
Sob (COCI19_sob) |
C++14 |
|
333 ms |
11320 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define ll long long
#define F first
#define S second
#define pb push_back
#define md ((b + e) >> 1)
#define lc (ind << 1)
#define rc (lc | 1)
const ll N = 1e6+ 10;
const ll lg = 15;
const ll oo = 1e9 + 10;
const ll mod = 1e9 + 7;
vector < pair <int, int> > solve(int n, int m){
vector < pair <int, int> > ret = {};
if (n <= 3){
vector <int> A = {}, B = {};
for (int i = 0; i < n; i ++){
A.pb(i);
B.pb(m + i);
}
do {
bool ok = 1;
for (int i = 0; i < n; i ++){
ok &= ((A[i] & B[i]) == A[i]);
}
if (ok){
break;
}
} while (next_permutation(B.begin(), B.end()));
for (int i = 0; i < n; i ++){
ret.pb({A[i], B[i]});
}
return ret;
}
vector < pair <int, int> > o = {}, e = {};
if (n & 1){
if (m & 1){
o = solve((n - 2) / 2 + 1, (m + 2) / 2);
e = solve((n - 1) / 2 + 1, m / 2);
}
else {
o = solve((n - 2) / 2 + 1, (m + 1) / 2);
e = solve((n - 1) / 2 + 1, m / 2);
}
}
else {
if (m & 1){
o = solve((n - 1) / 2 + 1, m / 2);
e = solve((n - 2) / 2 + 1, (m + 1) / 2);
}
else {
o = solve((n - 1) / 2 + 1, (m + 1) / 2);
e = solve((n - 2) / 2 + 1, m / 2);
}
}
for (auto it : o){
ret.pb({it.F * 2 + 1, it.S * 2 + 1});
}
for (auto it : e){
ret.pb({it.F * 2, it.S * 2});
if (it.S == m / 2 && (n & 1) && (m & 1)){
ret.back().S ++;
}
}
return ret;
}
int n, m;
vector < pair <int, int> > ans;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> m;
ans = solve(n, m);
for (auto it : ans){
cout << it.F << ' ' << it.S << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
272 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
149 ms |
6052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
152 ms |
6048 KB |
Output is correct |
7 |
Correct |
84 ms |
3076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
272 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
149 ms |
6052 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
152 ms |
6048 KB |
Output is correct |
11 |
Correct |
84 ms |
3076 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
39 ms |
1508 KB |
Output is correct |
20 |
Correct |
112 ms |
4668 KB |
Output is correct |
21 |
Correct |
5 ms |
568 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
192 ms |
6724 KB |
Output is correct |
24 |
Correct |
333 ms |
11320 KB |
Output is correct |
25 |
Correct |
296 ms |
11096 KB |
Output is correct |