# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
26453 |
2017-06-30T21:45:42 Z |
pacu |
Park (JOI17_park) |
C++ |
|
213 ms |
2160 KB |
#include "park.h"
#include <cstdlib>
#include <vector>
using namespace std;
static int place[1400];
int nNodes;
void clear()
{
for(int j=0;j<nNodes;j++)
place[j] = 0;
}
void fill()
{
for(int j=0;j<nNodes;j++)
place[j] = 1;
}
void ansEdge(int a,int b)
{
if(a>b) swap(a,b);
Answer(a,b);
}
int question(int a,int b,int p[])
{
if(a>b) swap(a,b);
return Ask(a,b,p);
}
void solveRange(int l,int r,vector<int> lst)
{
if(lst.size()==0)
{
ansEdge(l,r);
return;
}
int mid = lst[rand()%lst.size()];
vector<int> lList,rList;
for(int j=0;j<lst.size();j++) if(lst[j]!=mid)
{
fill();
place[lst[j]] = 0;
if(question(l,mid,place)) rList.push_back(lst[j]);
else lList.push_back(lst[j]);
}
solveRange(l,mid,lList);
solveRange(mid,r,rList);
}
void Detect(int T,int N)
{
nNodes = N;
if(T==1)
{
for(int i=0;i<N;i++)
for(int j=i+1;j<N;j++)
{
clear();
place[i] = place[j] = 1;
if(Ask(i,j,place))
ansEdge(i,j);
}
}
if(T==2)
{
vector<int> lst;
for(int i=1;i<N-1;i++)
lst.push_back(i);
solveRange(0,N-1,lst);
}
}
Compilation message
park.cpp: In function 'void solveRange(int, int, std::vector<int>)':
park.cpp:42:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<lst.size();j++) if(lst[j]!=mid)
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2028 KB |
Output is correct |
2 |
Correct |
9 ms |
2028 KB |
Output is correct |
3 |
Correct |
9 ms |
2028 KB |
Output is correct |
4 |
Correct |
9 ms |
2028 KB |
Output is correct |
5 |
Correct |
9 ms |
2028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
203 ms |
2160 KB |
Output is correct |
2 |
Correct |
123 ms |
2160 KB |
Output is correct |
3 |
Correct |
119 ms |
2160 KB |
Output is correct |
4 |
Correct |
176 ms |
2028 KB |
Output is correct |
5 |
Correct |
213 ms |
2160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2028 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2028 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2028 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |