Submission #1122723

#TimeUsernameProblemLanguageResultExecution timeMemory
1122723aaaaaarrozSphinx's Riddle (IOI24_sphinx)C++20
31 / 100
43 ms916 KiB
#include <bits/stdc++.h> using namespace std; int perform_experiment(vector<int> e); vector<int>alll(int n,vector<int> x,vector<int> y){ vector<int>color(n); for(int i=0;i<n;i++){ vector<int>nodos; for(int j=0;j<n;j++){ if(j!=i){ nodos.push_back(j); } } int l=0,r=n-1; while(l<r){ int mid=(l+r)/2; vector<int>exp(n,l); exp[i]=-1; int node=0; for(int j=l;j<=mid;j++){ exp[nodos[node]]=j; node++; } int experimento=perform_experiment(exp); if(experimento==(mid-l+1)){ r=mid; } else{ l=mid+1; } } color[i]=l; } return color; } vector<int> uno(int n, vector<int>& x, vector<int>& y) { vector<int> color(n, -1); vector<vector<int>> adj(n); for (int i = 0; i < x.size(); i++) { adj[x[i]].push_back(y[i]); adj[y[i]].push_back(x[i]); } color[0] = 0; queue<int> q; q.push(0); while (!q.empty()) { int curr = q.front(); q.pop(); for (int neighbor : adj[curr]) { if (color[neighbor] == -1) { vector<int> exp(n, -1); exp[curr] = color[curr]; exp[neighbor] = !color[curr]; int result = perform_experiment(exp); color[neighbor] = (result == 1) ? color[curr] : !color[curr]; q.push(neighbor); } } } return color; } vector<int> find_colours(int n,vector<int> x,vector<int> y){ vector<int>grado(n,0); for(int i=0;i<x.size();i++){ grado[x[i]]++; grado[y[i]]++; } bool all=true; for(int i=0;i<n;i++){ if(grado[i]!=(n-1)){ all=false; } } if(n<=50){ vector<int> color(n, -1); for (int i = 0; i < n; ++i) { for (int c = 0; c < n; ++c){ vector<int> e(n, c); e[i] = -1; int foo = perform_experiment(e); if (foo == 1) { color[i] = c; break; } } } return color; } if(all){ return alll(n,x,y); } return uno(n,x,y); }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...