#include "highway.h"
#include <iostream>
using namespace std;
int m,ans[1000005],tag[105];
int find(int s,int e)
{
std::vector<int> w(m);
for(int i=0;i<=m;i++)
{
w[i] = 0;
}
for(int i=s;i<=e;i++)
{
w[i]=1;
}
int t=ask(w);
if(t==e-s+1)
{
for(int i=s;i<=e;i++)
{
ans[0]++;
ans[ans[0]]=i;
}
}
else if(t==0)return 0;
else
{
find(s,(s+e)/2);
find((s+e)/2,e);
}
}
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
m = U.size();
std::vector<int> w(m);
int tmp=ask(w);
if(N<=100)
{
for(int i=0;i<m;i++)
{
w[i]=1;
int t=ask(w);
if(t>tmp)
{
//cout<<i<<" "<<U[i]<<" "<<V[i]<<endl;
tag[U[i]]++;
tag[V[i]]++;
}
w[i]=0;
}
int s=-1,t=-1;
for(int i=0;i<N;i++)
{
if(tag[i]==1)
{
if(s==-1)s=i;
else t=i;
}
}
return answer(s,t);
}
find(0,m);
int s=N+1,t=0;
for(int i=1;i<=ans[0];i++)
{
s=min(ans[i],s);
t=max(ans[i]+1,t);
}
answer(s, t);
}
Compilation message
highway.cpp: In function 'int find(int, int)':
highway.cpp:31:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
296 KB |
Output is correct |
3 |
Correct |
3 ms |
292 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
296 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
296 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
248 KB |
Output is correct |
10 |
Correct |
3 ms |
248 KB |
Output is correct |
11 |
Correct |
3 ms |
248 KB |
Output is correct |
12 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
632 KB |
Output is incorrect: more than 100 calls to ask. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
4312 KB |
Output is incorrect: more than 100 calls to ask. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
772 KB |
Output is incorrect: more than 100 calls to ask. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
4808 KB |
Output is incorrect: more than 100 calls to ask. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
4768 KB |
Output is incorrect: more than 100 calls to ask. |
2 |
Halted |
0 ms |
0 KB |
- |