Submission #2169910
Source Code Expand
#include <cstdio> #include <iostream> #include <algorithm> #include <string> #include <cstring> #include <vector> #include <queue> #include <set> #include <map> #include <cmath> #include <iomanip> #include <cassert> #include <bitset> using namespace std; typedef pair<int, int> P; #define rep(i, n) for (int i=0; i<(n); i++) #define all(c) (c).begin(), (c).end() #define uniq(c) c.erase(unique(all(c)), (c).end()) #define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin()) #define _1 first #define _2 second #define pb push_back #define INF 1145141919 #define MOD 1000000007 int N; int A[200]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; rep(i, N) cin >> A[i]; vector<int> seq; rep(t, N) { int pos = -1; rep(x, N) if (A[x] == N-1-t) pos = x; if (pos == N-1-t) continue; // [pos+1, N-1-t] for (int i=1; i<=N; i++) { seq.pb(1); if (pos+1 <= i && i <= N-1-t) seq.pb(N-1); } swap(A[pos], A[N-1-t]); } assert(is_sorted(A, A+N)); cout << seq.size() << "\n"; for (int x : seq) cout << x << "\n"; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Many Swaps Sorting |
User | funcsr |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1143 Byte |
Status | WA |
Exec Time | 5 ms |
Memory | 640 KB |
Judge Result
Set Name | Sample | Subtask1 | Subtask2 | All | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | 0 / 400 | 0 / 200 | ||||||||||||||
Status |
|
|
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt |
Subtask1 | 00_example_01.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt |
Subtask2 | 00_example_01.txt, 00_example_02.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt, s2_07.txt, s2_08.txt, s2_09.txt, s2_10.txt, s2_11.txt |
All | 00_example_01.txt, 00_example_02.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt, s2_07.txt, s2_08.txt, s2_09.txt, s2_10.txt, s2_11.txt, s3_12.txt, s3_13.txt, s3_14.txt, s3_15.txt, s3_16.txt, s3_17.txt, s3_18.txt, s3_19.txt, s3_20.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | WA | 1 ms | 256 KB |
00_example_02.txt | WA | 1 ms | 256 KB |
s1_01.txt | WA | 1 ms | 256 KB |
s1_02.txt | WA | 1 ms | 256 KB |
s1_03.txt | WA | 1 ms | 256 KB |
s1_04.txt | WA | 1 ms | 256 KB |
s1_05.txt | WA | 1 ms | 256 KB |
s1_06.txt | AC | 1 ms | 256 KB |
s2_07.txt | WA | 1 ms | 256 KB |
s2_08.txt | WA | 1 ms | 256 KB |
s2_09.txt | WA | 1 ms | 256 KB |
s2_10.txt | WA | 1 ms | 256 KB |
s2_11.txt | WA | 1 ms | 256 KB |
s3_12.txt | WA | 2 ms | 384 KB |
s3_13.txt | WA | 3 ms | 512 KB |
s3_14.txt | WA | 2 ms | 384 KB |
s3_15.txt | WA | 2 ms | 384 KB |
s3_16.txt | WA | 3 ms | 640 KB |
s3_17.txt | WA | 5 ms | 640 KB |
s3_18.txt | WA | 5 ms | 640 KB |
s3_19.txt | WA | 3 ms | 640 KB |
s3_20.txt | AC | 1 ms | 256 KB |