제출 #165378

#제출 시각아이디문제언어결과실행 시간메모리
165378dolphingarlicJOIRIS (JOI16_joiris)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> #define FOR(i, x, y) for (int i = x; i < y; i++) typedef long long ll; using namespace std; int a[50], b[50]; vector<pair<int, int>> moves; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, k, mx = -1, sm = 0; cin >> n >> k; FOR(i, 1, n + 1) { cin >> a[i]; b[i] = a[i] & 1; mx = max(mx, a[i] - b[i]); sm += a[i]; } if (sm & 1) return cout << -1, 0; FOR(i, 1, n + 1) { while (a[i] - b[i] < mx) { a[i] += 2; moves.push_back({1, i}); } } bool l = false, r = false; FOR(i, 1, n + 1) { if (!b[i]) { moves.push_back({1, i}); b[i] = 1; int j; for (j = i - 1; j > 1; j -= 2) moves.push_back({2, j - 1}); if (j == 1) { l = !l; if (l) moves.push_back({1, 1}); } for (j = i + 1; j < n; j += 2) { if (!b[j]) { moves.push_back({1, j}); b[j] = 1; j++; } if (j < n) moves.push_back({2, j}); else j -= 2; } if (j == n) { r = !r; if (r) moves.push_back({1, n}); } } } if (!(l ^ r)) { for (int i = 2; i < n; i += 2) moves.push_back({2, i}); } else return cout << -1, 0; cout << moves.size() << '\n'; for (pair<int, int> i : moves) cout << i.first << ' ' << i.second << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...