답안 #165378

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
165378 2019-11-26T16:15:37 Z dolphingarlic JOIRIS (JOI16_joiris) C++14
0 / 100
2 ms 376 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -