# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1007045 | 2024-06-24T11:04:19 Z | De3b0o | Longest Trip (IOI23_longesttrip) | C++17 | 31 ms | 1156 KB |
#include "longesttrip.h" #include<bits/stdc++.h> #include<random> #define ll long long #define F first #define S second #define in insert #define pb push_back #define ppb pop_back() #define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define cans cout << ans << "\n"; #define yes cout << "Yes" << "\n"; #define no cout << "No" << "\n"; #define pll pair<ll,ll> #define lin cout << "\n"; #define sqr 340 #define mod 1000000007 #define mid ((l+r)/2) #define lc (2*n) #define rc (2*n+1) using namespace std; ll v[300][300]; vector<ll> adj[300]; ll mx; vector<int> trnbo; void lt(ll x , set<ll> s , vector<int> t) { ll e = 0; for(auto it : adj[x]) { if(s.find(it)!=s.end()) continue; e++; set<ll> ss = s; vector<int> tt = t; tt.pb(it); ss.in(it); lt(it,ss,tt); } if(e==0) { if(t.size()>mx) { mx=t.size(); trnbo=t; } } } std::vector<int> longest_trip(int N, int D) { memset(v,-1,sizeof(v)); ll n = N; ll e = 32640; for(int i = 0 ; n>i ; i++) { for(int j = i+1 ; n>j ; j++) { if(e==0) break; if(v[i][j]!=-1) continue; e--; v[i][j]=are_connected({i},{j}); v[j][i]=v[i][j]; } vector<ll> z; for(int j = 0 ; n>j ; j++) { if(i==j) continue; if(v[i][j]==0) z.pb(j); } if(z.size()>1) { for(int i1 = 0 ; z.size()>i1 ; i1++) { for(int i2 = 0 ; z.size()>i2 ; i2++) { if(i1==i2) continue; v[i1][i2]=1; v[i2][i1]=1; } } } } for(int i = 0 ; n>i ; i++) { for(int j = 0 ; n>i ; i++) { if(v[i][j]==1) adj[i].pb(j); } } for(int i = 0 ; n>i ; i++) lt(i,{i},{i}); return trnbo; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 1112 KB | Incorrect |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 1112 KB | Incorrect |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 1112 KB | Incorrect |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 1156 KB | Output is correct |
2 | Incorrect | 1 ms | 1112 KB | Incorrect |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 1112 KB | Incorrect |
2 | Halted | 0 ms | 0 KB | - |