/*#include "avoid.h"
#include <bits/stdc++.h>
using namespace std;
int ind[10][10];
int save[10];
int p[20];
int find(int a) {
return p[a]<0?a:p[a]=find(p[a]);
}
void merge(int a,int b) {
a=find(a);
b=find(b);
if (a==b) {
return;
}
p[b]=a;
}
std::pair<int, int> scout(int R, int H) {
vector<int> v[75];
for(int i=0;i<10;i++) {
for(int j=1;j<=1000;j++) {
if (j&(1<<i)) {
v[i].push_back(j);
}
else {
v[10+i].push_back(j);
}
}
}
int cnt=20;
for(int i=0;i<10;i++) {
for(int j=i+1;j<10;j++) {
for(int k=1;k<=1000;k++) {
if ((k&(1<<i))&&(k&(1<<j))) {
v[cnt].push_back(k);
}
}
ind[i][j]=cnt++;
}
}
for(int i=0;i<cnt;i++) {
send(v[i]);
}
memset(p,-1,sizeof(p));
vector<int> got=wait();
for(int i=0;i<10;i++) {
if (got[i]==0&&got[10+i]==1) {
save[i]=0;
}
else if (got[i]==1&&got[10+i]==0) {
save[i]=1;
}
else {
save[i]=-1;
}
}
for(int i=0;i<10;i++) {
for(int j=i+1;j<10;j++) {
if (save[i]==-1&&save[j]==-1) {
if (got[ind[i][j]]==1) {
merge(i,j);
merge(10+i,10+j);
}
else {
merge(i,10+j);
merge(10+i,j);
}
}
}
}
int one=0;
int two=0;
int st=-1;
for(int i=9;i>=0;i--) {
if (save[i]==-1) {
st=i;
}
else {
one+=(save[i]<<i);
two+=(save[i]<<i);
}
}
if (st!=-1)
two+=(1<<st);
for(int i=0;i<10;i++) {
if (save[i]==-1&&i!=st) {
if (find(i)==find(st)) {
two+=(1<<i);
}
else {
one+=(1<<i);
}
}
}
return pair<int,int>(one,two);
}*/
#include "avoid.h"
#include <bits/stdc++.h>
using namespace std;
int ind[10][10];
int save[10];
int p[20];
int find(int a) {
return p[a]<0?a:p[a]=find(p[a]);
}
void merge(int a,int b) {
a=find(a);
b=find(b);
if (a==b) {
return;
}
p[b]=a;
}
std::pair<int, int> scout(int R, int H) {
vector<int> v[75];
for(int i=0;i<10;i++) {
for(int j=1;j<=1000;j++) {
if (j&(1<<i)) {
v[i].push_back(j);
}
}
}
int cnt=10;
for(int i=0;i<cnt;i++) {
send(v[i]);
}
memset(p,-1,sizeof(p));
vector<int> got=wait();
for(int i=0;i<10;i++) {
if (got[i]==0) {
save[i]=0;
}
else if (got[i]==1) {
save[i]=1;
}
}
for(int i=0;i<10;i++) {
for(int j=i+1;j<10;j++) {
if (save[i]==-1&&save[j]==-1) {
if (got[ind[i][j]]==1) {
merge(i,j);
merge(10+i,10+j);
}
else {
merge(i,10+j);
merge(10+i,j);
}
}
}
}
int one=0;
int two=0;
int st=-1;
for(int i=9;i>=0;i--) {
if (save[i]==-1) {
st=i;
}
else {
one+=(save[i]<<i);
two+=(save[i]<<i);
}
}
if (st!=-1)
two+=(1<<st);
for(int i=0;i<10;i++) {
if (save[i]==-1&&i!=st) {
if (find(i)==find(st)) {
two+=(1<<i);
}
else {
one+=(1<<i);
}
}
}
return pair<int,int>(one,two);
}
Compilation message
avoid.cpp: In function 'std::pair<int, int> scout(int, int)':
avoid.cpp:171:1: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
171 | if (st!=-1)
| ^~
avoid.cpp:173:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
173 | for(int i=0;i<10;i++) {
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Correct: 10 robot(s) used, 1 hour(s) passed |
2 |
Correct |
0 ms |
344 KB |
Correct: 10 robot(s) used, 1 hour(s) passed |
3 |
Correct |
0 ms |
344 KB |
Correct: 10 robot(s) used, 1 hour(s) passed |
4 |
Correct |
0 ms |
344 KB |
Correct: 10 robot(s) used, 1 hour(s) passed |
5 |
Correct |
0 ms |
344 KB |
Correct: 10 robot(s) used, 1 hour(s) passed |
6 |
Correct |
0 ms |
344 KB |
Correct: 10 robot(s) used, 1 hour(s) passed |
7 |
Correct |
0 ms |
344 KB |
Correct: 10 robot(s) used, 1 hour(s) passed |
8 |
Correct |
0 ms |
344 KB |
Correct: 10 robot(s) used, 1 hour(s) passed |
9 |
Correct |
1 ms |
344 KB |
Correct: 10 robot(s) used, 1 hour(s) passed |
10 |
Correct |
0 ms |
344 KB |
Correct: 10 robot(s) used, 1 hour(s) passed |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
464 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |