# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
962626 | 2024-04-14T04:09:02 Z | Warinchai | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 7 ms | 600 KB |
#include "longesttrip.h" #include<bits/stdc++.h> using namespace std; vector<int>longest_trip_3(int N){ vector<int>ans; for(int i=0;i<N;i++)ans.push_back(i); return ans; } vector<int>longest_trip_2(int N){ vector<int>ans; vector<int>tans; tans.push_back(0); for(int i=1;i<N;i++){ if(are_connected({i-1},{i}))tans.push_back(i); else if(i!=N-1)tans.push_back(i+1),tans.push_back(i),i++; else ans.push_back(i); } for(auto x:tans)ans.push_back(x); return ans; } int vis[256]; int fnext(int x,int sz){ int st=0,en=sz-1,ans=0; int id=-1; vector<int>ask; while(st<=en){ int m=(st+en)/2; ask.clear(); int cur=0; while(ask.size()<sz){ if(!vis[cur])ask.push_back(cur); cur++; } if(are_connected({x},ask)){ st=m+1; ans=m; id=cur-1; }else{ en=m-1; } } return id; } vector<int>longest_trip_1(int N){ for(int i=0;i<256;i++)vis[i]=0; vector<int>ans; ans.push_back(0); vis[0]=1; int cur=0,left=N; while(1){ int x=fnext(cur,left); if(x!=-1){ cur=x; left--; ans.push_back(cur); }else{ break; } } if(ans.size()>=(N+1)/2)return ans; else{ ans.clear(); for(int i=0;i<N;i++)if(!vis[i])ans.push_back(i); return ans; } return ans; } vector<int> longest_trip(int N, int D) { if(D==1)return longest_trip_1(N); else if(D==2)return longest_trip_2(N); else return longest_trip_3(N); return {}; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | invalid array |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 6 ms | 600 KB | Output is correct |
6 | Correct | 5 ms | 344 KB | Output is correct |
7 | Correct | 5 ms | 344 KB | Output is correct |
8 | Correct | 6 ms | 344 KB | Output is correct |
9 | Correct | 5 ms | 344 KB | Output is correct |
10 | Correct | 5 ms | 344 KB | Output is correct |
11 | Correct | 6 ms | 600 KB | Output is correct |
12 | Correct | 5 ms | 344 KB | Output is correct |
13 | Correct | 5 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | invalid array |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | invalid array |
2 | Halted | 0 ms | 0 KB | - |