Submission #708217

#TimeUsernameProblemLanguageResultExecution timeMemory
708217happypotatoMemory 2 (JOI16_memory2)C++17
10 / 100
1 ms340 KiB
#include "Memory2_lib.h" #include <bits/stdc++.h> using namespace std; int buff[101][101]; int ans[101]; int ask(int x, int y) { if (buff[x][y] != -1) return buff[x][y]; return buff[x][y] = Flip(x, y); } int add(vector<int> &v) { int mini = 100; for (int i = 0; i < 4; i++) { for (int j = i + 1; j < 4; j++) { mini = min(mini, ask(v[i], v[j])); } } for (int i = 0; i < 4; i++) { int cnt = 0; for (int j = 0; j < 4; j++) { if (i == j) continue; cnt += (ask(v[i], v[j]) == mini); } if (cnt == 3) { ans[v[i]] = mini; return i; } } return -1; } void Solve(int T, int n){ for (int i = 0; i < 2 * n; i++) { for (int j = 0; j < 2 * n; j++) { buff[i][j] = -1; } } vector<int> v = {0, 1, 2, 3}; for (int i = 4; i < 2 * n; i++) { v[add(v)] = i; } int rem = add(v); vector<int> left; for (int i = 0; i < 4; i++) { if (i != rem) left.push_back(v[i]); } vector<int> queries; queries.push_back(ask(left[0], left[1])); queries.push_back(ask(left[0], left[2])); queries.push_back(ask(left[1], left[2])); if (queries[0] == queries[1]) { ans[left[1]] = ans[left[2]] = queries[2]; ans[left[0]] = queries[0]; } else if (queries[0] == queries[2]) { ans[left[0]] = ans[left[2]] = queries[1]; ans[left[1]] = queries[0]; } else if (queries[1] == queries[2]) { ans[left[0]] = ans[left[1]] = queries[0]; ans[left[2]] = queries[1]; } for (int i = 0; i < n; i++) { pair<int, int> res = {-1, -1}; for (int j = 0; j < 2 * n; j++) { if (ans[j] == i) { if (res.first == -1) res.first = j; else res.second = j; } } Answer(res.first, res.second, i); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...