# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1060026 | 2024-08-15T10:09:12 Z | noyancanturk | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 7 ms | 440 KB |
#include "longesttrip.h" #include <bits/stdc++.h> using namespace std; #define pb push_back int n,d; vector<int> longest_trip(int N, int D) { n=N,d=D; vector<int>trip; trip.pb(0); int root1=0,root2=0; for(int i=0;i+1<n;i++){ bool ok=are_connected({i},{i+1}); if(!ok){ root1=i,root2=i+1; break; }else{ trip.pb(i+1); } } if(trip.size()==n)return trip; vector<int>cmp1,cmp2; //cerr<<"roots "<<root1<<" "<<root2<<"\n"; cmp1.pb(root1); cmp2.pb(root2); for(int i=0;i<n;i++){ if(i==root1||i==root2)continue; bool ok=are_connected({root1},{i}); if(ok){ //cerr<<i<<" in cmp1\n"; cmp1.pb(i); }else{ //cerr<<i<<" in cmp2\n"; cmp2.pb(i); } } if(cmp2.size()<cmp1.size()){ swap(cmp1,cmp2); swap(root1,root2); } int link=-1; for(int i:cmp1){ bool ok=are_connected({i},cmp2); if(ok){ link=i; break; } } if(link==-1){ return cmp2; } //cerr<<"found link "<<link<<"\n"; vector<int>path; for(int i:cmp1){ if(i!=link)path.pb(i); } path.pb(link); for(int i:cmp2){ if(i!=link)path.pb(i); } return path; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 1 ms | 436 KB | Incorrect |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 344 KB | Output is correct |
2 | Correct | 6 ms | 344 KB | Output is correct |
3 | Correct | 5 ms | 344 KB | Output is correct |
4 | Correct | 5 ms | 344 KB | Output is correct |
5 | Correct | 5 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 344 KB | Output is correct |
2 | Correct | 5 ms | 344 KB | Output is correct |
3 | Correct | 3 ms | 340 KB | Output is correct |
4 | Correct | 5 ms | 344 KB | Output is correct |
5 | Correct | 5 ms | 344 KB | Output is correct |
6 | Incorrect | 0 ms | 344 KB | Incorrect |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 344 KB | Output is correct |
2 | Correct | 5 ms | 344 KB | Output is correct |
3 | Correct | 5 ms | 344 KB | Output is correct |
4 | Correct | 4 ms | 344 KB | Output is correct |
5 | Correct | 5 ms | 440 KB | Output is correct |
6 | Incorrect | 0 ms | 344 KB | Incorrect |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 344 KB | Output is correct |
2 | Correct | 7 ms | 344 KB | Output is correct |
3 | Correct | 5 ms | 344 KB | Output is correct |
4 | Correct | 5 ms | 344 KB | Output is correct |
5 | Correct | 5 ms | 344 KB | Output is correct |
6 | Incorrect | 0 ms | 344 KB | Incorrect |
7 | Halted | 0 ms | 0 KB | - |