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 "islands.h"
#include <variant>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fs first
#define sc second
std::variant<bool, std::vector<int>> find_journey(
int N, int M, std::vector<int> U, std::vector<int> V) {
if(N == 2){
vector<int> cnt[2];
for(int i = 0;i<M;i++){
int a = U[i],b = V[i];
cnt[a].push_back(i);
}
if(cnt[0].size()<2||cnt[1].size()<1)return false;
int x = cnt[0][0],y = cnt[1][0],z = cnt[0][1];
return vector<int>({x,y,z,x,y,z});
}
else{
if(N<=2)return false;
int mxn = 440;
int arr[mxn][mxn];
for(int i = 0;i<M;i++){
int a = U[i],b = V[i];
arr[a][b] = i;
}
pii a = pii(arr[0][1],arr[1][0]),b = pii(arr[1][2],arr[2][1]),c = pii(arr[2][0],arr[0][2]);
return vector<int>({a.fs,b.fs,c.fs,c.sc,b.sc,a.sc,c.fs,b.fs,a.fs,a.sc,b.sc,c.sc});
}
}
Compilation message (stderr)
islands.cpp: In function 'std::variant<bool, std::vector<int, std::allocator<int> > > find_journey(int, int, std::vector<int>, std::vector<int>)':
islands.cpp:16:17: warning: unused variable 'b' [-Wunused-variable]
16 | int a = U[i],b = V[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... |