#include <bits/stdc++.h>
#include "swaps.h"
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("avx2")
using namespace std;
typedef long long ll;
typedef pair<int, int> pp;
#define er(args ...) cerr << __LINE__ << ": ", err(new istringstream(string(#args)), args), cerr << endl
#define per(i,r,l) for(int i = (r); i >= (l); i--)
#define rep(i,l,r) for(int i = (l); i < (r); i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define ss second
#define ff first
void err(istringstream *iss){}template<typename T,typename ...Args> void err(istringstream *iss,const T &_val, const Args&...args){string _name;*iss>>_name;if(_name.back()==',')_name.pop_back();cerr<<_name<<" = "<<_val<<", ",err(iss,args...);}
void IOS(){
cin.tie(0) -> sync_with_stdio(0);
#ifndef ONLINE_JUDGE
freopen("in.in", "r", stdin);
freopen("out.out", "w", stdout);
#endif
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod = 1e9 + 7, maxn = 1e5 + 5, lg = 22, inf = ll(1e9) + 5;
ll pw(ll a,ll b,ll md=mod){if(!b)return 1;ll k=pw(a,b>>1ll);return k*k%md*(b&1ll?a:1)%md;}
void solve(int n, int v){
vector<int> id(n); iota(all(id), 1);
while(v--){
for(int i = v&1; i < n-1; i += 2) schedule(id[i], id[i+1]);
vector<int> res = visit();
for(int i = v&1; i < n-1; i += 2) if(res[i>>1]^1) swap(id[i], id[i+1]);
}
answer(id);
}
// int main(){ IOS();
// return 0;
// }
Compilation message
swaps.cpp: In function 'void IOS()':
swaps.cpp:20:18: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
20 | freopen("in.in", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
swaps.cpp:21:18: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
21 | freopen("out.out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
208 KB |
Correct |
2 |
Correct |
105 ms |
208 KB |
Correct |
3 |
Correct |
224 ms |
288 KB |
Correct |
4 |
Correct |
468 ms |
372 KB |
Correct |
5 |
Correct |
410 ms |
508 KB |
Correct |
6 |
Correct |
371 ms |
408 KB |
Correct |
7 |
Correct |
472 ms |
440 KB |
Correct |
8 |
Correct |
427 ms |
500 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
208 KB |
Correct |
2 |
Correct |
114 ms |
208 KB |
Correct |
3 |
Correct |
249 ms |
284 KB |
Correct |
4 |
Correct |
441 ms |
492 KB |
Correct |
5 |
Correct |
414 ms |
412 KB |
Correct |
6 |
Correct |
464 ms |
404 KB |
Correct |
7 |
Correct |
471 ms |
412 KB |
Correct |
8 |
Correct |
421 ms |
372 KB |
Correct |
9 |
Correct |
94 ms |
388 KB |
Correct |
10 |
Correct |
84 ms |
308 KB |
Correct |
11 |
Correct |
86 ms |
308 KB |
Correct |
12 |
Correct |
88 ms |
308 KB |
Correct |
13 |
Correct |
87 ms |
460 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
208 KB |
Correct |
2 |
Correct |
117 ms |
208 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
208 KB |
Correct |
2 |
Correct |
117 ms |
208 KB |
Correct |
3 |
Correct |
49 ms |
208 KB |
Correct |
4 |
Correct |
139 ms |
208 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
208 KB |
Correct |
2 |
Correct |
103 ms |
336 KB |
Correct |
3 |
Correct |
211 ms |
300 KB |
Correct |
4 |
Correct |
417 ms |
528 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
208 KB |
Correct |
2 |
Correct |
103 ms |
336 KB |
Correct |
3 |
Correct |
211 ms |
300 KB |
Correct |
4 |
Correct |
417 ms |
528 KB |
Correct |
5 |
Correct |
44 ms |
208 KB |
Correct |
6 |
Correct |
120 ms |
284 KB |
Correct |
7 |
Correct |
230 ms |
284 KB |
Correct |
8 |
Correct |
445 ms |
408 KB |
Correct |
9 |
Correct |
406 ms |
532 KB |
Correct |
10 |
Correct |
398 ms |
404 KB |
Correct |
11 |
Correct |
428 ms |
392 KB |
Correct |
12 |
Correct |
437 ms |
396 KB |
Correct |
13 |
Correct |
51 ms |
208 KB |
Correct |
14 |
Correct |
132 ms |
292 KB |
Correct |
15 |
Correct |
259 ms |
284 KB |
Correct |
16 |
Correct |
426 ms |
336 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
208 KB |
Correct |
2 |
Correct |
107 ms |
208 KB |
Correct |
3 |
Correct |
222 ms |
284 KB |
Correct |
4 |
Correct |
425 ms |
356 KB |
Correct |
5 |
Correct |
54 ms |
352 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
208 KB |
Correct |
2 |
Correct |
107 ms |
208 KB |
Correct |
3 |
Correct |
222 ms |
284 KB |
Correct |
4 |
Correct |
425 ms |
356 KB |
Correct |
5 |
Correct |
54 ms |
352 KB |
Correct |
6 |
Correct |
44 ms |
208 KB |
Correct |
7 |
Correct |
132 ms |
208 KB |
Correct |
8 |
Correct |
232 ms |
280 KB |
Correct |
9 |
Correct |
451 ms |
476 KB |
Correct |
10 |
Correct |
428 ms |
392 KB |
Correct |
11 |
Correct |
440 ms |
528 KB |
Correct |
12 |
Correct |
480 ms |
428 KB |
Correct |
13 |
Correct |
432 ms |
416 KB |
Correct |
14 |
Correct |
93 ms |
304 KB |
Correct |
15 |
Correct |
80 ms |
308 KB |
Correct |
16 |
Correct |
95 ms |
308 KB |
Correct |
17 |
Correct |
87 ms |
308 KB |
Correct |
18 |
Correct |
89 ms |
356 KB |
Correct |
19 |
Correct |
56 ms |
208 KB |
Correct |
20 |
Correct |
111 ms |
208 KB |
Correct |
21 |
Correct |
235 ms |
284 KB |
Correct |
22 |
Correct |
465 ms |
496 KB |
Correct |
23 |
Correct |
43 ms |
400 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
208 KB |
Correct |
2 |
Correct |
101 ms |
208 KB |
Correct |
3 |
Correct |
211 ms |
284 KB |
Correct |
4 |
Correct |
400 ms |
468 KB |
Correct |
5 |
Correct |
44 ms |
312 KB |
Correct |
6 |
Incorrect |
8 ms |
292 KB |
Not correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
208 KB |
Correct |
2 |
Correct |
101 ms |
208 KB |
Correct |
3 |
Correct |
211 ms |
284 KB |
Correct |
4 |
Correct |
400 ms |
468 KB |
Correct |
5 |
Correct |
44 ms |
312 KB |
Correct |
6 |
Incorrect |
8 ms |
292 KB |
Not correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
208 KB |
Correct |
2 |
Correct |
118 ms |
208 KB |
Correct |
3 |
Correct |
218 ms |
284 KB |
Correct |
4 |
Correct |
426 ms |
536 KB |
Correct |
5 |
Correct |
53 ms |
404 KB |
Correct |
6 |
Incorrect |
10 ms |
288 KB |
Not correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
208 KB |
Correct |
2 |
Correct |
118 ms |
208 KB |
Correct |
3 |
Correct |
218 ms |
284 KB |
Correct |
4 |
Correct |
426 ms |
536 KB |
Correct |
5 |
Correct |
53 ms |
404 KB |
Correct |
6 |
Incorrect |
10 ms |
288 KB |
Not correct |
7 |
Halted |
0 ms |
0 KB |
- |