Submission #944915

#TimeUsernameProblemLanguageResultExecution timeMemory
944915Tuanlinh123Chameleon's Love (JOI20_chameleon)C++17
40 / 100
16 ms4412 KiB
#include "chameleon.h" #include<bits/stdc++.h> #define ll int #define pll pair<ll, ll> #define pb push_back #define mp make_pair #define fi first #define se second #define ld long double #define sz(a) ((ll)(a).size()) using namespace std; void Solve(ll n) { vector <ll> love(n*2+1, 0), loved(n*2+1, 0), res(n*2+1, 0); vector <vector <ll>> ans(n*2+1, vector <ll> (n*2+1, 0)), sus(n*2+1); for (ll i=1; i<=n*2; i++) for (ll j=i+1; j<=n*2; j++) { ans[i][j]=ans[j][i]=Query(vector <ll>{i, j}); if (ans[i][j]==1) sus[i].pb(j), sus[j].pb(i); } for (ll i=1; i<=n*2; i++) { if (sz(sus[i])==1) { res[i]=sus[i][0], res[sus[i][0]]=i; continue; } assert(sz(sus[i])==3); for (ll j=0; j<3; j++) if (Query(vector <ll>{i, sus[i][j], sus[i][(j+1)%3]})==1) love[i]=sus[i][(j+2)%3], loved[sus[i][(j+2)%3]]=i; } for (ll i=1; i<=n*2; i++) { if (sz(sus[i])==1) continue; for (ll j:sus[i]) if (j!=love[i] && j!=loved[i]) res[i]=j, res[j]=i; } for (ll i=1; i<=n*2; i++) { if (!res[i]) continue; Answer(i, res[i]), res[i]=res[res[i]]=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...