# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
576173 |
2022-06-12T12:39:43 Z |
urd05 |
Park (JOI17_park) |
C++17 |
|
222 ms |
468 KB |
#include "park.h"
#include <bits/stdc++.h>
using namespace std;
int place[1400];
int n;
bool comp(int a,int b) {
for(int i=0;i<n;i++) {
if (i==a) {
place[i]=0;
}
else {
place[i]=1;
}
}
if (Ask(0,b,place)==0) {
return true;
}
else {
return false;
}
}
void Detect(int t,int nn) {
n=nn;
if (t==1) {
for(int i=0;i<n;i++) {
for(int j=i+1;j<n;j++) {
for(int k=0;k<n;k++) {
if (k==i||k==j) {
place[k]=1;
}
else {
place[k]=0;
}
}
if (Ask(i,j,place)==1) {
Answer(i,j);
}
}
}
return;
}
if (t==2) {
vector<int> vec;
for(int i=1;i<n-1;i++) {
vec.push_back(i);
}
sort(vec.begin(),vec.end(),comp);
Answer(0,vec[0]);
Answer(vec[vec.size()-1],n-1);
for(int i=1;i<vec.size();i++) {
int one=vec[i-1];
int two=vec[i];
Answer(min(one,two),max(one,two));
}
return;
}
if (t==3) {
vector<int> vec[10];
bool vis[1400];
memset(vis,0,sizeof(vis));
vis[0]=true;
vec[0].push_back(0);
for(int j=1;j<=9;j++) {
memset(place,0,sizeof(place));
for(int k=0;k<j;k++) {
for(int i=0;i<vec[k].size();i++) {
place[vec[k][i]]=1;
}
}
for(int i=0;i<n;i++) {
if (!vis[i]) {
memset(place,0,sizeof(place));
for(int k=0;k<j;k++) {
for(int i=0;i<vec[k].size();i++) {
place[vec[k][i]]=1;
}
}
place[i]=1;
if (Ask(0,i,place)==1) {
vec[j].push_back(i);
vis[i]=true;
}
}
}
for(int i=0;i<vec[j].size();i++) {
int now=vec[j][i];
int l=0;
int r=vec[j-1].size()-1;
while (l<r) {
int mid=(l+r)/2;
memset(place,0,sizeof(place));
for(int k=0;k<j-1;k++) {
for(int i=0;i<vec[k].size();i++) {
place[vec[k][i]]=1;
}
}
for(int k=l;k<=mid;k++) {
place[vec[j-1][k]]=1;
}
place[now]=1;
if (Ask(0,now,place)==1) {
r=mid;
}
else {
l=mid+1;
}
}
Answer(min(vec[j-1][l],now),max(vec[j-1][l],now));
}
}
}
}
Compilation message
park.cpp: In function 'void Detect(int, int)':
park.cpp:53:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for(int i=1;i<vec.size();i++) {
| ~^~~~~~~~~~~
park.cpp:69:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for(int i=0;i<vec[k].size();i++) {
| ~^~~~~~~~~~~~~~
park.cpp:77:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
77 | for(int i=0;i<vec[k].size();i++) {
| ~^~~~~~~~~~~~~~
park.cpp:88:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
88 | for(int i=0;i<vec[j].size();i++) {
| ~^~~~~~~~~~~~~~
park.cpp:96:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
96 | for(int i=0;i<vec[k].size();i++) {
| ~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
12 ms |
324 KB |
Output is correct |
3 |
Correct |
13 ms |
324 KB |
Output is correct |
4 |
Correct |
13 ms |
324 KB |
Output is correct |
5 |
Correct |
14 ms |
324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
194 ms |
448 KB |
Output is correct |
2 |
Correct |
84 ms |
448 KB |
Output is correct |
3 |
Correct |
107 ms |
448 KB |
Output is correct |
4 |
Correct |
200 ms |
340 KB |
Output is correct |
5 |
Correct |
222 ms |
448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
396 KB |
Output is correct |
2 |
Correct |
100 ms |
400 KB |
Output is correct |
3 |
Correct |
101 ms |
404 KB |
Output is correct |
4 |
Correct |
69 ms |
412 KB |
Output is correct |
5 |
Correct |
106 ms |
340 KB |
Output is correct |
6 |
Correct |
90 ms |
468 KB |
Output is correct |
7 |
Correct |
71 ms |
404 KB |
Output is correct |
8 |
Correct |
101 ms |
396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |