This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "island.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>order[305];
map<pair<int,int>,int>mp;
int child[305];
bool check(int p,int ch,int pch){
//cerr<<"pchild:"<<pch<<"\n";
for(int i=0;i<order[pch].size();i++){
if(order[pch][i]==p)return true;
else if(child[order[pch][i]])return false;
}
return true;
}
void solve(int N, int L) {
for(int i=1;i<=N;i++){
for(int j=1;j<=2;j++){
int x=query(i,j);
order[i].push_back(x);
}
}
for(int i=1;i<=N;i++){
//cerr<<i<<"\n";
for(int i=1;i<=N;i++)child[i]=0;
int ch=order[i][0];
//cerr<<"child:"<<ch<<"\n";
child[ch]=1;
if(!mp[{ch,i}])mp[{ch,i}]++,mp[{i,ch}]++,answer(i,ch);
int cur=1;
if(cur<N-1&&check(i,ch,order[i][cur])){
if(!mp[{order[i][cur],i}])mp[{order[i][cur],i}]++,mp[{i,order[i][cur]}]++,answer(i,order[i][cur]);
child[order[i][cur]]=1;
cur++;
}
}
}
Compilation message (stderr)
island.cpp: In function 'bool check(int, int, int)':
island.cpp:9:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
9 | for(int i=0;i<order[pch].size();i++){
| ~^~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |