제출 #972089

#제출 시각아이디문제언어결과실행 시간메모리
972089steveonalexChameleon's Love (JOI20_chameleon)C++17
40 / 100
15 ms344 KiB
#include <bits/stdc++.h> #include "chameleon.h" using namespace std; typedef long long ll; typedef unsigned long long ull; #define ALL(v) (v).begin(), (v).end() #define MASK(i) (1LL << (i)) #define GETBIT(mask, i) (((mask) >> (i)) & 1) // mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); mt19937_64 rng(1); ll rngesus(ll l, ll r){return ((ull) rng()) % (r - l + 1) + l;} ll max(ll a, ll b){return (a > b) ? a : b;} ll min(ll a, ll b){return (a < b) ? a : b;} ll LASTBIT(ll mask){return mask & (-mask);} ll pop_cnt(ll mask){return __builtin_popcountll(mask);} ll ctz(ll mask){return __builtin_ctzll(mask);} ll clz(ll mask){return __builtin_clzll(mask);} ll logOf(ll mask){return 63 - clz(mask);} template <class T1, class T2> bool minimize(T1 &a, T2 b){ if (a > b){a = b; return true;} return false; } template <class T1, class T2> bool maximize(T1 &a, T2 b){ if (a < b){a = b; return true;} return false; } template <class T> void printArr(T& a, string separator = " ", string finish = "\n", ostream& out = cout){ for(auto i: a) out << i << separator; out << finish; } template <class T> void remove_dup(vector<T> &a){ sort(ALL(a)); a.resize(unique(ALL(a)) - a.begin()); } // namespace Grader{ // int n; // vector<int> Y, C, L; // vector<int> check; // int o_cnt, ans; // int Query(const vector<int> &p){ // o_cnt++; // vector<bool> state(n * 2 + 1); // for(int i: p) state[i] = 1; // vector<bool> color(n*2+1); // for(int i: p){ // if (state[L[i]]) color[C[L[i]]] = 1; // else color[C[i]] = 1; // } // int ans = 0; // for(int i = 1; i<=2*n; ++i) ans += color[i]; // return ans; // } // void Answer(int x, int y){ // cout << "! " << x << " " << y << "\n"; // if (C[x] != C[y]) ans = false; // check[x]++; check[y]++; // } void Solve(int n){ vector<vector<int>> graph(n*2+1); for(int i = 1; i<=2*n; ++i) for(int j = i + 1; j<=2*n; ++j){ vector<int> ask = {i, j}; if (Query(ask) == 1) { graph[i].push_back(j); graph[j].push_back(i); } } for(int i = 1; i<=2*n; ++i) if (graph[i].size() != 1){ pair<int, int> legit = {-1, -1}; for(int j = 0; j < 3; ++j) for(int k = j + 1; k < 3; ++k){ vector<int> ask = {i, graph[i][j], graph[i][k]}; if (Query(ask) == 1) { legit = {graph[i][j], graph[i][k]}; break; } } graph[i] = {legit.first, legit.second}; } for(int i = 1; i<=2*n; ++i) sort(ALL(graph[i])); for(int i = 1; i<=2*n; ++i){ for(int j: graph[i]) if (j > i){ if (binary_search(ALL(graph[j]), i)) Answer(i, j); } } } // pair<bool, int> run_test(int _n){ // n = _n; // Y.resize(n * 2 + 1); L = C = Y; // for(int i= 1; i<=2*n; ++i) cin >> Y[i]; // for(int i= 1; i<=2*n; ++i) cin >> C[i]; // for(int i= 1; i<=2*n; ++i) cin >> L[i]; // o_cnt = 0; ans = 1; // check = vector<int>(2*n+1); // Solve(n); // if (*max_element(1+ALL(check)) != 1 || *min_element(1+ALL(check)) != 1) ans = false; // return {ans, o_cnt}; // } // } // int main(void){ // ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // int n; cin >> n; // pair<bool, int> verdict = Grader::run_test(n); // if (verdict.first) cout << "AC\n"; // else cout << "WA\n"; // cout << "Total operation count: " << verdict.second << "\n"; // return 0; // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...