Submission #1103401

#TimeUsernameProblemLanguageResultExecution timeMemory
1103401Tibi201Mouse (info1cup19_mouse)C++14
0 / 100
1 ms592 KiB
#include <grader.h> #include <stdio.h> #include <stdlib.h> #include <set> #include <vector> #include <time.h> #define MAXN 256 int solved[MAXN]; std::set <int> cand[MAXN],used; std::vector <int> q; int ramase[MAXN]; void fill(int n){ int i,j,n2; n2=n; for(i=0; i<n2; i++){ ramase[i]=i+1; } for(auto x : used){ ramase[x-1]=0; } for(i=0; i<n2; i++){ if(ramase[i]==0){ for(j=i+1; j<n2; j++){ ramase[j-1]=ramase[j]; } n2--; } } for(i=0; i<n; i++){ if(solved[i]==0){ j=rand()%n2; q[j]=ramase[j]; for(j=j+1; j<n2; j++){ ramase[j-1]=ramase[j]; } n2--; } } } void solve(int N) { srand(time(NULL)); int i,j,x,n=N; auto y=used.begin(); for(i=0; i<n; i++){ for(j=1; j<=n; j++){ cand[i].insert(j); } } for(i=0; i<n; i++){ x=0; while(solved[x]==1) x++; for(j=x+1; j<n; j++){ if((int)cand[j].size()<(int)cand[x].size()) x=j; } y=cand[x].begin(); y--; while((int)cand[i].size()>1){ y++; if(y==cand[x].end()) y=cand[x].begin(); q[x+1]=*y; used.insert(*y); fill(n); if(query(q)==i){ for(j=i; j<n; j++) cand[j].erase(cand[j].find(q[j])); } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...