#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
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)
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
167 ms |
732 KB |
Output is correct |
2 |
Correct |
136 ms |
772 KB |
Output is correct |
3 |
Correct |
164 ms |
716 KB |
Output is correct |
4 |
Correct |
126 ms |
672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
218 ms |
732 KB |
Output is correct |
2 |
Correct |
197 ms |
728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
195 ms |
672 KB |
Output is correct |
2 |
Correct |
205 ms |
684 KB |
Output is correct |
3 |
Correct |
183 ms |
684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
211 ms |
792 KB |
Output is correct |
2 |
Correct |
214 ms |
672 KB |
Output is correct |
3 |
Correct |
162 ms |
724 KB |
Output is correct |
4 |
Correct |
192 ms |
712 KB |
Output is correct |
5 |
Correct |
186 ms |
728 KB |
Output is correct |
6 |
Correct |
209 ms |
696 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
210 ms |
812 KB |
Output is correct |
2 |
Correct |
207 ms |
848 KB |
Output is correct |
3 |
Correct |
195 ms |
700 KB |
Output is correct |
4 |
Correct |
151 ms |
856 KB |
Output is correct |
5 |
Correct |
203 ms |
724 KB |
Output is correct |
6 |
Correct |
190 ms |
672 KB |
Output is correct |
7 |
Correct |
181 ms |
804 KB |
Output is correct |