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 "islands.h"
using namespace std;
variant<bool, std::vector<int>> find_journey(int N,int M,vector<int> U,vector<int> V){
if(N==2){
int Back=-1;
int Front_1=-1;
int Front_2=-1;
vector<int> S;
for(int i=0;i<M;i++){
if(!(Back+1) && U[i]==1) Back=i;
else if(!(Front_1+1) && V[i]==1) Front_1=i;
else if(!(Front_2+1) && V[i]==1) Front_2=i;
}
if(!(Back+1) || !(Front_1+1) || !(Front_2+1)) return false;
S.push_back(Front_1);
S.push_back(Back);
S.push_back(Front_2);
S.push_back(Front_1);
S.push_back(Back);
S.push_back(Front_2);
return S;
}
int Node1=-1,Node2=-1,Node3=-1;
int a=-1,b=-1,c=-1,d=-1;
//vector<int> S;
for(int i=0;i<M;i++){
if(U[i]==0 && Node1==-1){
a=i;
Node1=V[i];
}
else if(U[i]==0 && Node2==-1){
c=i;
Node2=V[i];
}
}
for(int i=0;i<M;i++){
if(U[i]==Node1 && V[i]==0 && b==-1) b=i;
else if(U[i]==Node2 && V[i]==0 && d==-1) d=i;
}
if(c!=-1){
vector<int> S={a,b,c,d,b,a,d,c};
return S;
}
for(int i=0;i<M;i++){
if(U[i]==Node1 && c==-1 && V[i]!=0){
c=i;
Node3=V[i];
}
}
for(int i=0;i<M;i++){
if(U[i]==Node3 && V[i]==Node1 && d==-1) d=i;
}
if(c!=-1){
vector<int> S={a,b,d,c,b,d,c,a};
return S;
}
return false;
}
# | 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... |