Submission #34477325
Source Code Expand
#include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <algorithm> #include <cmath> using namespace std; #define mp make_pair #define pb push_back #define ll long long const int maxN = 200011; int n, v[maxN]; vector<int> ans; int main() { cin >> n; n <<= 1; for (int i = 1; i <= n; i++) cin >> v[i]; for (int i = 2; i <= n; i += 2) { if (v[i] > v[i - 1] && v[i] > v[i + 1]) continue; if (v[i - 1] > v[i + 1]) { ans.pb(i - 1); swap(v[i - 1], v[i]); } else { ans.pb(i); swap(v[i], v[i + 1]); } } cout << ans.size() << '\n'; for (auto e : ans) cout << e << ' '; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Make it Zigzag |
User | atatomir |
Language | C++ (GCC 9.2.1) |
Score | 400 |
Code Size | 724 Byte |
Status | AC |
Exec Time | 60 ms |
Memory | 4536 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00-sample-001.txt, 00-sample-002.txt |
All | 00-sample-001.txt, 00-sample-002.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, after-contest-001.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00-sample-001.txt | AC | 15 ms | 3404 KiB |
00-sample-002.txt | AC | 2 ms | 3432 KiB |
01-001.txt | AC | 2 ms | 3492 KiB |
01-002.txt | AC | 3 ms | 3456 KiB |
01-003.txt | AC | 2 ms | 3448 KiB |
01-004.txt | AC | 3 ms | 3424 KiB |
01-005.txt | AC | 2 ms | 3420 KiB |
01-006.txt | AC | 5 ms | 3408 KiB |
01-007.txt | AC | 46 ms | 4128 KiB |
01-008.txt | AC | 25 ms | 3864 KiB |
01-009.txt | AC | 50 ms | 4280 KiB |
01-010.txt | AC | 13 ms | 3640 KiB |
01-011.txt | AC | 43 ms | 4148 KiB |
01-012.txt | AC | 55 ms | 4316 KiB |
01-013.txt | AC | 56 ms | 4228 KiB |
01-014.txt | AC | 60 ms | 4432 KiB |
01-015.txt | AC | 58 ms | 4536 KiB |
01-016.txt | AC | 57 ms | 4452 KiB |
01-017.txt | AC | 58 ms | 4456 KiB |
01-018.txt | AC | 59 ms | 4508 KiB |
01-019.txt | AC | 57 ms | 4436 KiB |
01-020.txt | AC | 50 ms | 4256 KiB |
01-021.txt | AC | 59 ms | 4500 KiB |
after-contest-001.txt | AC | 6 ms | 3512 KiB |