답안 #167838

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167838 2019-12-10T10:53:34 Z TAISA_ Memory 2 (JOI16_memory2) C++14
100 / 100
2 ms 376 KB
#include "Memory2_lib.h"
#include <bits/stdc++.h>
using namespace std;
void Solve(int T, int N) {
    vector<int> vis(2 * N), res(2 * N), co(N);
    for (int i = 0; i < 2 * N; i++) {
        if (vis[i]) {
            continue;
        }
        vector<int> c(N), r(2 * N);
        bool f = true;
        for (int j = i + 1; j < 2 * N; j++) {
            if (vis[j]) {
                continue;
            }
            r[j] = Flip(i, j);
            c[r[j]]++;
            if (co[r[j]] + c[r[j]] > 2) {
                f = false;
                for (int k = i + 1; k < j; k++) {
                    if (vis[k]) {
                        continue;
                    }
                    if (r[k] != r[j]) {
                        res[k] = r[k];
                        vis[k] = 1;
                        co[r[k]]++;
                    }
                }
                res[i] = r[j];
                vis[i] = 1;
                co[r[j]]++;
                break;
            }
        }
        if (f) {
            for (int j = i + 1; j < 2 * N; j++) {
                if (vis[j]) {
                    continue;
                }
                res[j] = r[j];
                co[r[j]]++;
            }
            for (int j = 0; j < N; j++) {
                if (co[j] == 1) {
                    res[i] = j;
                    break;
                }
            }
            break;
        }
    }
    vector<vector<int>> v(N);
    for (int i = 0; i < 2 * N; i++) {
        v[res[i]].push_back(i);
    }
    for (int i = 0; i < N; i++) {
        //   cout << v[i][0] << " " << v[i][1] << endl;
        Answer(v[i][0], v[i][1], i);
    }
    return;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 372 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 360 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 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 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct