//
// --- Sample implementation for the task swaps ---
//
// To compile this program with the sample grader, place:
// swaps.h swaps_sample.cpp sample_grader.cpp
// in a single folder and run:
// g++ swaps_sample.cpp sample_grader.cpp
// in this folder.
//
#include "swaps.h"
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
using ll = long long;
using ld = long double;
const string FILENAME = "input";
vector<int> r;
vector<pair<int, int> > q;
void add(int i, int j) {
schedule(r[i], r[j]);
q.pb(mp(i, j));
}
void myVist() {
if (sz(q) == 0) {
return;
}
vector<int> res = visit();
for (int i = 0; i < sz(res); i++) {
if (!res[i]) {
swap(r[q[i].first], r[q[i].second]);
}
}
q.clear();
}
void solve(int n, int v) {
for (int i = 1; i <= n; i++) {
r.pb(i);
}
for (int k = 2; k <= 2 * n; k <<= 1) {
for (int i = 0; i < n; i++) {
int l = i ^ (k - 1);
if (i < l && l < n) {
add(i, l);
}
}
myVist();
for (int j = k >> 2; j > 0; j >>= 1) {
for (int i = 0; i < n; i++) {
int l = i ^ j;
if (i < l && l < n) {
add(i, l);
}
}
myVist();
}
}
answer(r);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
2 ms |
200 KB |
Correct |
3 |
Correct |
3 ms |
200 KB |
Correct |
4 |
Correct |
7 ms |
304 KB |
Correct |
5 |
Correct |
6 ms |
300 KB |
Correct |
6 |
Correct |
6 ms |
300 KB |
Correct |
7 |
Correct |
6 ms |
300 KB |
Correct |
8 |
Correct |
5 ms |
296 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
2 ms |
296 KB |
Correct |
3 |
Correct |
3 ms |
200 KB |
Correct |
4 |
Correct |
6 ms |
296 KB |
Correct |
5 |
Correct |
5 ms |
300 KB |
Correct |
6 |
Correct |
6 ms |
296 KB |
Correct |
7 |
Correct |
6 ms |
300 KB |
Correct |
8 |
Correct |
6 ms |
300 KB |
Correct |
9 |
Correct |
6 ms |
300 KB |
Correct |
10 |
Correct |
6 ms |
300 KB |
Correct |
11 |
Correct |
6 ms |
300 KB |
Correct |
12 |
Correct |
5 ms |
300 KB |
Correct |
13 |
Correct |
6 ms |
296 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
2 ms |
200 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
2 ms |
200 KB |
Correct |
3 |
Correct |
1 ms |
200 KB |
Correct |
4 |
Correct |
2 ms |
200 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
2 ms |
200 KB |
Correct |
3 |
Correct |
3 ms |
200 KB |
Correct |
4 |
Correct |
5 ms |
300 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
2 ms |
200 KB |
Correct |
3 |
Correct |
3 ms |
200 KB |
Correct |
4 |
Correct |
5 ms |
300 KB |
Correct |
5 |
Correct |
1 ms |
200 KB |
Correct |
6 |
Correct |
1 ms |
200 KB |
Correct |
7 |
Correct |
3 ms |
200 KB |
Correct |
8 |
Correct |
6 ms |
296 KB |
Correct |
9 |
Correct |
6 ms |
300 KB |
Correct |
10 |
Correct |
6 ms |
300 KB |
Correct |
11 |
Correct |
6 ms |
296 KB |
Correct |
12 |
Correct |
7 ms |
296 KB |
Correct |
13 |
Correct |
1 ms |
200 KB |
Correct |
14 |
Correct |
2 ms |
200 KB |
Correct |
15 |
Correct |
3 ms |
200 KB |
Correct |
16 |
Correct |
6 ms |
296 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
2 ms |
200 KB |
Correct |
3 |
Correct |
3 ms |
200 KB |
Correct |
4 |
Correct |
6 ms |
300 KB |
Correct |
5 |
Correct |
5 ms |
336 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
2 ms |
200 KB |
Correct |
3 |
Correct |
3 ms |
200 KB |
Correct |
4 |
Correct |
6 ms |
300 KB |
Correct |
5 |
Correct |
5 ms |
336 KB |
Correct |
6 |
Correct |
1 ms |
200 KB |
Correct |
7 |
Correct |
2 ms |
200 KB |
Correct |
8 |
Correct |
3 ms |
200 KB |
Correct |
9 |
Correct |
7 ms |
304 KB |
Correct |
10 |
Correct |
7 ms |
296 KB |
Correct |
11 |
Correct |
6 ms |
296 KB |
Correct |
12 |
Correct |
5 ms |
304 KB |
Correct |
13 |
Correct |
6 ms |
296 KB |
Correct |
14 |
Correct |
6 ms |
296 KB |
Correct |
15 |
Correct |
6 ms |
304 KB |
Correct |
16 |
Correct |
6 ms |
296 KB |
Correct |
17 |
Correct |
6 ms |
300 KB |
Correct |
18 |
Correct |
6 ms |
300 KB |
Correct |
19 |
Correct |
1 ms |
200 KB |
Correct |
20 |
Correct |
2 ms |
200 KB |
Correct |
21 |
Correct |
3 ms |
200 KB |
Correct |
22 |
Correct |
6 ms |
296 KB |
Correct |
23 |
Correct |
6 ms |
300 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
2 ms |
200 KB |
Correct |
3 |
Correct |
3 ms |
200 KB |
Correct |
4 |
Correct |
6 ms |
296 KB |
Correct |
5 |
Correct |
5 ms |
300 KB |
Correct |
6 |
Correct |
6 ms |
280 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
2 ms |
200 KB |
Correct |
3 |
Correct |
3 ms |
200 KB |
Correct |
4 |
Correct |
6 ms |
296 KB |
Correct |
5 |
Correct |
5 ms |
300 KB |
Correct |
6 |
Correct |
6 ms |
280 KB |
Correct |
7 |
Correct |
1 ms |
200 KB |
Correct |
8 |
Correct |
2 ms |
200 KB |
Correct |
9 |
Correct |
3 ms |
200 KB |
Correct |
10 |
Correct |
7 ms |
296 KB |
Correct |
11 |
Correct |
5 ms |
296 KB |
Correct |
12 |
Correct |
7 ms |
420 KB |
Correct |
13 |
Correct |
5 ms |
300 KB |
Correct |
14 |
Correct |
6 ms |
296 KB |
Correct |
15 |
Correct |
5 ms |
296 KB |
Correct |
16 |
Correct |
6 ms |
304 KB |
Correct |
17 |
Correct |
6 ms |
296 KB |
Correct |
18 |
Correct |
6 ms |
296 KB |
Correct |
19 |
Correct |
6 ms |
296 KB |
Correct |
20 |
Correct |
1 ms |
200 KB |
Correct |
21 |
Correct |
2 ms |
276 KB |
Correct |
22 |
Correct |
3 ms |
200 KB |
Correct |
23 |
Correct |
6 ms |
296 KB |
Correct |
24 |
Correct |
6 ms |
296 KB |
Correct |
25 |
Correct |
6 ms |
276 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
1 ms |
200 KB |
Correct |
3 |
Correct |
3 ms |
200 KB |
Correct |
4 |
Correct |
6 ms |
384 KB |
Correct |
5 |
Correct |
6 ms |
280 KB |
Correct |
6 |
Correct |
6 ms |
284 KB |
Correct |
7 |
Correct |
5 ms |
280 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Correct |
2 |
Correct |
1 ms |
200 KB |
Correct |
3 |
Correct |
3 ms |
200 KB |
Correct |
4 |
Correct |
6 ms |
384 KB |
Correct |
5 |
Correct |
6 ms |
280 KB |
Correct |
6 |
Correct |
6 ms |
284 KB |
Correct |
7 |
Correct |
5 ms |
280 KB |
Correct |
8 |
Correct |
1 ms |
200 KB |
Correct |
9 |
Correct |
1 ms |
200 KB |
Correct |
10 |
Correct |
1 ms |
296 KB |
Correct |
11 |
Correct |
3 ms |
200 KB |
Correct |
12 |
Correct |
5 ms |
300 KB |
Correct |
13 |
Correct |
6 ms |
304 KB |
Correct |
14 |
Correct |
6 ms |
304 KB |
Correct |
15 |
Correct |
6 ms |
420 KB |
Correct |
16 |
Correct |
6 ms |
296 KB |
Correct |
17 |
Correct |
6 ms |
296 KB |
Correct |
18 |
Correct |
7 ms |
296 KB |
Correct |
19 |
Correct |
5 ms |
300 KB |
Correct |
20 |
Correct |
7 ms |
300 KB |
Correct |
21 |
Correct |
6 ms |
300 KB |
Correct |
22 |
Correct |
1 ms |
200 KB |
Correct |
23 |
Correct |
2 ms |
288 KB |
Correct |
24 |
Correct |
3 ms |
200 KB |
Correct |
25 |
Correct |
7 ms |
296 KB |
Correct |
26 |
Correct |
6 ms |
284 KB |
Correct |
27 |
Correct |
6 ms |
276 KB |
Correct |
28 |
Correct |
6 ms |
400 KB |
Correct |