Submission #49791

# Submission time Handle Problem Language Result Execution time Memory
49791 2018-06-03T06:46:32 Z 강태규(#1279, imeimi2000) None (JOI16_memory2) C++11
100 / 100
3 ms 724 KB
#include "Memory2_lib.h"
#include <vector>

using namespace std;

struct asks {
    int a, b;
};

vector<asks> mp[50];
void Solve(int T, int n) {
    for (int i = 0; i < n; ++i) {
        mp[Flip(i << 1, i << 1 | 1)].push_back({ i << 1, i << 1 | 1 });
    }
    vector<int> two;
    for (int i = 0; i < n; ++i) {
        if (mp[i].size() == 2) two.push_back(i);
    }
    while (!two.empty()) {
        int t = two.back();
        two.pop_back();
        asks p = mp[t][0];
        asks q = mp[t][1];
        int x = Flip(p.a, q.a);
        int y = Flip(p.a, q.b);
        int z = Flip(p.b, q.a);
        int w = Flip(p.b, q.b);
        if (x != t) {
            Answer(p.b, q.b, t);
            mp[x].push_back({ p.a, q.a });
            if (mp[x].size() == 2) two.push_back(x);
        }
        else if (y != t) {
            Answer(p.b, q.a, t);
            mp[y].push_back({ p.a, q.b });
            if (mp[y].size() == 2) two.push_back(y);
        }
        else if (z != t) {
            Answer(p.a, q.b, t);
            mp[z].push_back({ p.b, q.a });
            if (mp[z].size() == 2) two.push_back(z);
        }
        else if (w != t) {
            Answer(p.a, q.a, t);
            mp[w].push_back({ p.b, q.b });
            if (mp[w].size() == 2) two.push_back(w);
        }
        mp[t].clear();
    }
    for (int i = 0; i < n; ++i) {
        if (mp[i].size()) Answer(mp[i][0].a, mp[i][0].b, i);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 528 KB Output is correct
4 Correct 2 ms 528 KB Output is correct
5 Correct 2 ms 528 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 2 ms 704 KB Output is correct
8 Correct 3 ms 704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 704 KB Output is correct
2 Correct 2 ms 704 KB Output is correct
3 Correct 2 ms 704 KB Output is correct
4 Correct 2 ms 704 KB Output is correct
5 Correct 2 ms 704 KB Output is correct
6 Correct 3 ms 704 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 3 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 2 ms 724 KB Output is correct
3 Correct 2 ms 724 KB Output is correct
4 Correct 2 ms 724 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 2 ms 724 KB Output is correct