Submission #737013

#TimeUsernameProblemLanguageResultExecution timeMemory
737013ibm2006Speedrun (RMI21_speedrun)C++14
100 / 100
218 ms856 KiB
#include<bits/stdc++.h> #include "speedrun.h" using namespace std; typedef int ll; ll c[1100],d[1100],z,h[1100]; vector<ll> v[1100]; void f(ll x,ll y) { ll i; c[x]=y; d[z]=x; z=x; for(i=0;i<h[x];i++) { if(v[x][i]==y) continue; f(v[x][i],x); } } void assignHints(ll subtask,ll N,ll A[],ll B[]) { ll i,n,x,j; n=N; for(i=1;i<=n;i++) {v[i].clear(); h[i]=0; } for(i=1;i<n;i++) { v[A[i]].push_back(B[i]); v[B[i]].push_back(A[i]); h[A[i]]++; h[B[i]]++; } f(1,0); setHintLen(20); for(i=1;i<=n;i++) { x=c[i]; for(j=1;j<=10;j++) { setHint(i,j,x%2); x/=2; } x=d[i]; for(j=11;j<=20;j++) { setHint(i,j,x%2); x/=2; } } } ll a[1100],b[1100]; ll g(ll x,ll y) { //printf("%d\n",x); ll i,j,r,z,w; if(c[x]==0) { c[x]=1; w=0; r=1; for(i=1;i<=10;i++) { w=getHint(i); if(z==1) w+=r; r*=2; } b[x]=w; w=0; r=1; for(i=1;i<=10;i++) { z=getHint(i+10); if(z==1) w+=r; r*=2; } a[x]=w; } ll k=a[x]; while(1) { if(k==0) return 0; if(goTo(k)) { k=g(k,x); } else { goTo(y); return k; } } } void speedrun(ll subtask,ll N,ll start) { ll i,x,y,r=1,z,n; bool t; x=start; n=N; for(i=1;i<=n;i++) c[i]=0; while(x!=1) { if(c[x]==0) { c[x]=1; y=0; r=1; for(i=1;i<=10;i++) { z=getHint(i); //printf("%d",z); if(z==1) y+=r; r*=2; } b[x]=y; y=0; r=1; //printf(" "); for(i=1;i<=10;i++) { z=getHint(i+10); //printf("%d",z); if(z==1) y+=r; r*=2; } a[x]=y; } x=b[x]; //printf(" %d\n",x); t=goTo(x); } g(x,0); }

Compilation message (stderr)

speedrun.cpp: In function 'll g(ll, ll)':
speedrun.cpp:56:10: warning: unused variable 'j' [-Wunused-variable]
   56 |     ll i,j,r,z,w;
      |          ^
speedrun.cpp: In function 'void speedrun(ll, ll, ll)':
speedrun.cpp:101:10: warning: variable 't' set but not used [-Wunused-but-set-variable]
  101 |     bool t;
      |          ^
speedrun.cpp: In function 'll g(ll, ll)':
speedrun.cpp:66:17: warning: 'z' may be used uninitialized in this function [-Wmaybe-uninitialized]
   66 |                 if(z==1)
      |                 ^~
#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...