제출 #599359

#제출 시각아이디문제언어결과실행 시간메모리
599359piOOEJOIRIS (JOI16_joiris)C++17
0 / 100
1 ms468 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; vector<int> a(n), b(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } b = a; for (int &i: b) { i &= 1; } bool yay[2] = {true, true}; for (int i = 0; i < n;) { int j = i; while (j < n && b[j] == b[i]) { j += 1; } int len = j - i; yay[b[i]] &= (len % 2 == 0); i = j; } vector<pair<int, int>> ans; if (yay[0]) { int mx = *max_element(a.begin(), a.end()); if (mx & 1) { for (int i = 0; i < n; ++i) { while (a[i] + 1 < mx) { ans.emplace_back(1, i); a[i] += 2; } } } else { for (int i = 0; i < n; ++i) { while (a[i] < mx) { a[i] += 2; ans.emplace_back(1, i); } } } auto [f, s] = minmax_element(a.begin(), a.end()); assert(*f + 1 == *s); mx = *f; int mn = *s; for (int i = 0; i < n;) { if (b[i] == 1) { i += 1; continue; } int j = i; while (j < n && b[i] == b[j]) { ans.emplace_back(2, j); j += 2; } i = j; } for (auto [x, y] : ans) { cout << x << " " << y + 1 << endl; } } else if (yay[1]) { int mx = *max_element(a.begin(), a.end()); if (mx & 1) { for (int i = 0; i < n; ++i) { while (a[i]< mx) { ans.emplace_back(1, i); a[i] += 2; } } } else { for (int i = 0; i < n; ++i) { while (a[i] + 1 < mx) { a[i] += 2; ans.emplace_back(1, i); } } } auto [f, s] = minmax_element(a.begin(), a.end()); assert(*f + 1 == *s); mx = *f; int mn = *s; for (int i = 0; i < n;) { b[i] = a[i] - mn; if (b[i] == 1) { i += 1; continue; } int j = i; while (j < n && b[i] == b[j]) { ans.emplace_back(2, j); j += 2; } i = j; } for (auto [x, y] : ans) { cout << x << " " << y + 1 << endl; } } else { cout << -1; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

joiris.cpp: In function 'int main()':
joiris.cpp:52:9: warning: unused variable 'mn' [-Wunused-variable]
   52 |     int mn = *s;
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...