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];
int n;
bool check(int p,int ch,int pch){
//cerr<<"pchild:"<<pch<<"\n";
for(int i=0;i<n-1;i++){
if(order[pch].size()<i+1)order[pch].push_back(query(pch,i+1));
if(order[pch][i]==p)return true;
else if(child[order[pch][i]])return false;
}
return true;
}
void solve(int N, int L) {
n=N;
/*for(int i=1;i<=N;i++){
for(int j=1;j<N;j++){
int x=query(i,j);
order[i].push_back(x);
}
}*/
//priority_queue<int,vector<int>,greater<int>>q;
//q.push(1);
int cnt=0;
for(int i=1;i<n;i++){
if(cnt==n-1)break;
//cerr<<i<<"\n";
int ocur=0;
ocur++;
if(order[i].size()<ocur)order[i].push_back(query(i,ocur));
for(int i=1;i<=N;i++)child[i]=0;
int ch=order[i][0];
if(order[ch].size()==0)order[ch].push_back(i);
//cerr<<"child:"<<ch<<"\n";
child[ch]=1;
if(!mp[{ch,i}])mp[{ch,i}]++,mp[{i,ch}]++,answer(i,ch),cnt++;
int cur=1;
ocur++;
if(order[i].size()<ocur)order[i].push_back(query(i,ocur));
while(cur<N-1&&check(i,ch,order[i][cur])){
///cerr<<"end\n";
if(!mp[{order[i][cur],i}])mp[{order[i][cur],i}]++,mp[{i,order[i][cur]}]++,answer(i,order[i][cur]),cnt++;
if(order[order[i][cur]].size()==0)order[order[i][cur]].push_back(i);
child[order[i][cur]]=1;
cur++;
ocur++;
if(order[i].size()<ocur&&ocur<N)order[i].push_back(query(i,ocur));
}
}
}
Compilation message (stderr)
island.cpp: In function 'bool check(int, int, int)':
island.cpp:11:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
11 | if(order[pch].size()<i+1)order[pch].push_back(query(pch,i+1));
| ~~~~~~~~~~~~~~~~~^~~~
island.cpp: In function 'void solve(int, int)':
island.cpp:33:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
33 | if(order[i].size()<ocur)order[i].push_back(query(i,ocur));
| ~~~~~~~~~~~~~~~^~~~~
island.cpp:42:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
42 | if(order[i].size()<ocur)order[i].push_back(query(i,ocur));
| ~~~~~~~~~~~~~~~^~~~~
island.cpp:50:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
50 | if(order[i].size()<ocur&&ocur<N)order[i].push_back(query(i,ocur));
| ~~~~~~~~~~~~~~~^~~~~
# | 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... |