//
// --- 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 <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
using namespace std;
using ll = long long;
template<class T, class U> bool chmin(T& a, const U& b) { return a > b ? a = b, true : false; }
template<class T, class U> bool chmax(T& a, const U& b) { return a < b ? a = b, true : false; }
void solve(int N, int V) {
vector<bool> used(N);
vector<int> ans;
rep (_, N) {
vector<int> vs;
rep (i, N) {
if (used[i]) continue;
vs.push_back(i);
}
while (vs.size() >= 2) {
vector<int> nv;
rep (i, vs.size() / 2) schedule(vs[i * 2] + 1, vs[i * 2 + 1] + 1);
auto res = visit();
rep (i, vs.size() / 2) {
if (res[i] == 1) nv.push_back(vs[i * 2]);
else nv.push_back(vs[i * 2 + 1]);
}
if (vs.size() % 2 == 1) nv.push_back(vs.back());
vs = nv;
}
used[vs[0]] = true;
ans.push_back(vs[0] + 1);
}
answer(ans);
}
/*
sub2. マージソートの各マージを並列にすると通る
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
3 ms |
344 KB |
Correct |
3 |
Correct |
11 ms |
344 KB |
Correct |
4 |
Correct |
41 ms |
448 KB |
Correct |
5 |
Correct |
35 ms |
452 KB |
Correct |
6 |
Correct |
38 ms |
672 KB |
Correct |
7 |
Correct |
40 ms |
500 KB |
Correct |
8 |
Correct |
38 ms |
516 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
4 ms |
344 KB |
Correct |
3 |
Correct |
11 ms |
344 KB |
Correct |
4 |
Correct |
41 ms |
452 KB |
Correct |
5 |
Correct |
36 ms |
560 KB |
Correct |
6 |
Correct |
39 ms |
340 KB |
Correct |
7 |
Correct |
50 ms |
772 KB |
Correct |
8 |
Correct |
55 ms |
448 KB |
Correct |
9 |
Runtime error |
13 ms |
440 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
3 ms |
344 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct |
2 |
Correct |
3 ms |
344 KB |
Correct |
3 |
Correct |
0 ms |
344 KB |
Correct |
4 |
Correct |
3 ms |
344 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
5 ms |
436 KB |
Correct |
3 |
Correct |
11 ms |
344 KB |
Correct |
4 |
Correct |
35 ms |
344 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
5 ms |
436 KB |
Correct |
3 |
Correct |
11 ms |
344 KB |
Correct |
4 |
Correct |
35 ms |
344 KB |
Correct |
5 |
Correct |
1 ms |
344 KB |
Correct |
6 |
Correct |
3 ms |
344 KB |
Correct |
7 |
Correct |
11 ms |
440 KB |
Correct |
8 |
Correct |
38 ms |
448 KB |
Correct |
9 |
Correct |
51 ms |
444 KB |
Correct |
10 |
Correct |
49 ms |
344 KB |
Correct |
11 |
Correct |
41 ms |
440 KB |
Correct |
12 |
Correct |
42 ms |
444 KB |
Correct |
13 |
Correct |
1 ms |
340 KB |
Correct |
14 |
Correct |
3 ms |
344 KB |
Correct |
15 |
Correct |
13 ms |
440 KB |
Correct |
16 |
Correct |
39 ms |
696 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
3 ms |
344 KB |
Correct |
3 |
Correct |
14 ms |
444 KB |
Correct |
4 |
Correct |
43 ms |
892 KB |
Correct |
5 |
Runtime error |
6 ms |
512 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
3 ms |
344 KB |
Correct |
3 |
Correct |
14 ms |
444 KB |
Correct |
4 |
Correct |
43 ms |
892 KB |
Correct |
5 |
Runtime error |
6 ms |
512 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
3 ms |
344 KB |
Correct |
3 |
Correct |
13 ms |
444 KB |
Correct |
4 |
Correct |
39 ms |
700 KB |
Correct |
5 |
Runtime error |
10 ms |
444 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
3 ms |
344 KB |
Correct |
3 |
Correct |
13 ms |
444 KB |
Correct |
4 |
Correct |
39 ms |
700 KB |
Correct |
5 |
Runtime error |
10 ms |
444 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
4 ms |
440 KB |
Correct |
3 |
Correct |
12 ms |
344 KB |
Correct |
4 |
Correct |
41 ms |
688 KB |
Correct |
5 |
Runtime error |
6 ms |
516 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct |
2 |
Correct |
4 ms |
440 KB |
Correct |
3 |
Correct |
12 ms |
344 KB |
Correct |
4 |
Correct |
41 ms |
688 KB |
Correct |
5 |
Runtime error |
6 ms |
516 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |