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 <bits/stdc++.h>
#include "island.h"
#define ll long long
#define pb push_back
#define S second
#define F first
#define pii pair<int,int>
#define vi vector <int>
#define vvi vector <vi>
#define vvvi vector <vvi>
#define vp vector <pii>
#define vvp vector <vp>
#define vb vector <bool>
#define vvb vector <vb>;
#define INF LLONG_MAX
#define MOD 1000000007
#define MAXN 300
using namespace std;
/*int query(int v,int k){
cout<<v<<" "<<k<<"ask\n";
int res;
cin>>res;
return res;
}
void answer(int x,int y){
cout<<x<<" "<<y<<"edgee\n";
}
*/
int par[MAXN+1];
vp active(MAXN+1);
int n;
void add(int x){
int k=active[x].S;
if (k==n)return;
k++;
if (k==n){active[x]={0,0};return;}
int res=query(x,k);
if (res!=par[x]){active[x]={res,k};return;}
k++;
if (k==n){active[x]={0,0};return;}
res=query(x,k);
if (res!=par[x]){active[x]={res,k};return;}
}
void solve(int N,int l){
n=N;
vi V;
for (int i=1;i<n;i++)V.pb(query(1,i));
vi cur={1};
active[1]={V[0],1};
vi next;
for (int x:V){
int vertice=0;
for (int y:next)if (active[y].F==x)vertice=y;
/// cout<<x<<'\n';
if (vertice){
/// cout<<"MAGIS QVEMOT\n";
answer(vertice,x);
par[x]=vertice;
add(x);
cur=next;
next={x};
}else{
for (int y:cur)if (active[y].F==x)vertice=y;
/// cout<<"IGIVE SIMAGLE\n";
answer(vertice,x);
par[x]=vertice;
add(vertice);
next.pb(x);
add(x);
}
}
}
/*signed main(){
int n,l;
cin>>n>>l;
solve(n,l);
}*/
# | 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... |