Submission #1001057

#TimeUsernameProblemLanguageResultExecution timeMemory
1001057UnforgettableplChameleon's Love (JOI20_chameleon)C++17
44 / 100
26 ms572 KiB
#include <bits/stdc++.h> using namespace std; int Query(const std::vector<int> &p); void Answer(int a, int b); void Solve(int N) { int n = N; vector<vector<int>> adj(2*n+1); set<pair<int,int>> edges; vector<vector<int>> sets(4); for(int i=1;i<=2*n;i++){ // Find all edges which correspond to vector<bool> present(4); for(int arr=0;arr<4;arr++){ vector<int> msuspects=sets[arr]; while(true){ auto base = Query(msuspects); msuspects.emplace_back(i); if(Query(msuspects)>base)break; msuspects.erase(--msuspects.end()); present[arr]=true; auto suspects = msuspects; while(suspects.size()>1){ int mid = suspects.size()/2; vector<int> left,right; for(int i=0;i<mid;i++)left.emplace_back(suspects[i]); for(int i=mid;i<suspects.size();i++)right.emplace_back(suspects[i]); auto b = left.size(); left.emplace_back(i); if(Query(left)>b)suspects=right; else { left.erase(--left.end()); suspects = left; } } msuspects.erase(lower_bound(msuspects.begin(),msuspects.end(),suspects[0])); edges.insert({min(i,suspects[0]),max(i,suspects[0])}); adj[i].emplace_back(suspects[0]); adj[suspects[0]].emplace_back(i); } } if(!present[0])sets[0].emplace_back(i); else if(!present[1])sets[1].emplace_back(i); else if(!present[2])sets[2].emplace_back(i); else if(!present[3])sets[3].emplace_back(i); } for(int i=1;i<=2*n;i++){ if(adj[i].size()==1)continue; assert(adj[i].size()==3); if(Query({i,adj[i][0],adj[i][1]})==1)edges.erase({min(i,adj[i][2]),max(i,adj[i][2])}); else if(Query({i,adj[i][0],adj[i][2]})==1)edges.erase({min(i,adj[i][1]),max(i,adj[i][1])}); else edges.erase({min(i,adj[i][0]),max(i,adj[i][0])}); } for(auto[a,b]:edges)Answer(a,b); }

Compilation message (stderr)

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:28:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |                  for(int i=mid;i<suspects.size();i++)right.emplace_back(suspects[i]);
      |                                ~^~~~~~~~~~~~~~~~
chameleon.cpp:31:32: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
   31 |                  if(Query(left)>b)suspects=right;
      |                     ~~~~~~~~~~~^~
#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...