Submission #1010721

#TimeUsernameProblemLanguageResultExecution timeMemory
1010721salmonChameleon's Love (JOI20_chameleon)C++14
100 / 100
85 ms652 KiB
#include "chameleon.h" #include <bits/stdc++.h> using namespace std; int lst[1100]; bool vis[1100]; vector<int> blonk; set<int> v[2]; vector<int> adjlst[1100]; int connect[1100]; void ffs(int i, int p){ v[1 - p].erase(i); v[p].insert(i); vis[i] = true; lst[i] = p; for(int j : adjlst[i]){ if(!vis[j]) ffs(j,1-p); } } int fid(vector<int> v, int i){ if(v.size() == 1) return v[0]; vector<int> temp = {i}; int m = (v.size() - 1)/2; for(int i = 0; i <= m; i++){ temp.push_back(v[i]); } if(temp.size() != Query(temp)){ temp.clear(); for(int i = 0; i <= m; i++){ temp.push_back(v[i]); } return fid(temp,i); } else{ temp.clear(); for(int i = m + 1; i < v.size(); i++){ temp.push_back(v[i]); } return fid(temp,i); } } void Solve(int N) { for(int i = 1; i <= N * 2; i++){ lst[i] = -1; } for(int i = 1; i <= N * 2; i++){ vector<int> temp(v[1].begin(),v[1].end()); vector<int> ext; vector<int> con; temp.push_back(i); while(temp.size() != Query(temp)){ for(int j = 1; j <= N * 2; j++){ vis[j] = false; } temp.pop_back(); int num = fid(temp,i); temp.push_back(i); ext.clear(); for(int i : temp){ if(i == num) continue; ext.push_back(i); } temp = ext; con.push_back(num); } temp.clear(); for(int i : v[0]){ temp.push_back(i); } temp.push_back(i); while(temp.size() != Query(temp)){ for(int j = 1; j <= N * 2; j++){ vis[j] = false; } temp.pop_back(); int num = fid(temp,i); temp.push_back(i); ext.clear(); for(int i : temp){ if(i == num) continue; ext.push_back(i); } temp = ext; con.push_back(num); } for(int j : con){ adjlst[i].push_back(j); adjlst[j].push_back(i); } for(int j = 1; j <= N * 2; j++){ vis[j] = false; } ffs(i,0); } for(int i = 1; i <= N * 2; i++) connect[i] = -1; for(int i = 1; i <= N * 2; i++){ if(adjlst[i].size() == 3){ int h1 = Query({i,adjlst[i][0],adjlst[i][1]}); int h2 = Query({i,adjlst[i][0],adjlst[i][2]}); int h3 = Query({i,adjlst[i][1],adjlst[i][2]}); if(h1 == h2){ connect[i] = adjlst[i][0]; } else if(h1 == h3){ connect[i] = adjlst[i][1]; } else{ connect[i] = adjlst[i][2]; } } } for(int i : v[0]){ if(adjlst[i].size() == 1){ Answer(i,adjlst[i][0]); } else{ for(int j : adjlst[i]){ if(connect[i] == j) continue; if(connect[j] == i) continue; Answer(i,j); } } } }

Compilation message (stderr)

chameleon.cpp: In function 'int fid(std::vector<int>, int)':
chameleon.cpp:34:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |     if(temp.size() != Query(temp)){
      |        ~~~~~~~~~~~~^~~~~~~~~~~~~~
chameleon.cpp:43:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for(int i = m + 1; i < v.size(); i++){
      |                            ~~^~~~~~~~~~
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:61:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |         while(temp.size() != Query(temp)){
      |               ~~~~~~~~~~~~^~~~~~~~~~~~~~
chameleon.cpp:86:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   86 |         while(temp.size() != Query(temp)){
      |               ~~~~~~~~~~~~^~~~~~~~~~~~~~
#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...