Submission #710471

#TimeUsernameProblemLanguageResultExecution timeMemory
710471myrcellaThousands Islands (IOI22_islands)C++17
1.75 / 100
265 ms4752 KiB
//by szh #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long,long long> #define pb push_back #define debug(x) cerr<<#x<<"="<<x<<endl #define pq priority_queue #define inf 0x3f #define rep(i,a,b) for (int i=a;i<(b);i++) #define MP make_pair #define SZ(x) (int(x.size())) #define ll long long #define mod 1000000007 #define ALL(x) x.begin(),x.end() void inc(int &a,int b) {a=(a+b)%mod;} void dec(int &a,int b) {a=(a-b+mod)%mod;} int lowbit(int x) {return x&(-x);} ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;} #include "islands.h" #include <variant> #include <vector> const int maxn = 1010; int dis[maxn][maxn]; vector <int> pos; vector <int> cyc; std::variant<bool, std::vector<int>> find_journey( int n, int M, std::vector<int> U, std::vector<int> V) { rep(i,0,M) { dis[U[i]][V[i]] = 1; if (U[i]==0) pos.pb(V[i]); } sort(ALL(pos)); pos.erase(unique(ALL(pos)),pos.end()); rep(k,0,n) rep(i,0,n) if (dis[i][k]) rep(j,0,n) { dis[i][j]|=dis[k][j]; } rep(i,0,n) if (dis[i][i]==1) cyc.pb(i); vector <int> ret; rep(i,0,SZ(pos)) rep(j,0,i) for (int k:cyc) { if (dis[pos[i]][k] and dis[pos[j]][k]) { // cout<<pos[i]<<" "<<pos[j]<<" "<<k<<endl; return ret; } } return false; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...