# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
962633 | 2024-04-14T04:43:38 Z | Warinchai | 가장 긴 여행 (IOI23_longesttrip) | C++17 | 55 ms | 700 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){ if(sz==0)return -1; //cerr<<"fnext:"<<x<<" "<<sz<<"\n"; int st=1,en=sz,ans=0; int id=-1; vector<int>ask; while(st<=en){ int m=(st+en)/2; ask.clear(); int cur=0; while(ask.size()<m){ if(!vis[cur])ask.push_back(cur); cur++; } //cerr<<m<<" ask:"; //for(auto x:ask)cerr<<x<<" "; //cerr<<"\n"; if(are_connected({x},ask)){ en=m-1; ans=m; id=cur-1; }else{ st=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-1; while(1){ //cerr<<cur<<"\n"; int x=fnext(cur,left); if(x!=-1){ cur=x; left--; ans.push_back(cur); vis[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); //cerr<<"end of query\n"; return {}; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 11 ms | 444 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 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 | 0 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 340 KB | Output is correct |
2 | Correct | 5 ms | 344 KB | Output is correct |
3 | Correct | 6 ms | 344 KB | Output is correct |
4 | Correct | 5 ms | 344 KB | Output is correct |
5 | Correct | 6 ms | 432 KB | Output is correct |
6 | Correct | 5 ms | 344 KB | Output is correct |
7 | Correct | 4 ms | 344 KB | Output is correct |
8 | Correct | 5 ms | 344 KB | Output is correct |
9 | Correct | 5 ms | 344 KB | Output is correct |
10 | Correct | 4 ms | 344 KB | Output is correct |
11 | Correct | 5 ms | 600 KB | Output is correct |
12 | Correct | 6 ms | 344 KB | Output is correct |
13 | Correct | 5 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 344 KB | Output is correct |
2 | Correct | 12 ms | 344 KB | Output is correct |
3 | Correct | 19 ms | 344 KB | Output is correct |
4 | Correct | 37 ms | 600 KB | Output is correct |
5 | Correct | 42 ms | 440 KB | Output is correct |
6 | Correct | 6 ms | 344 KB | Output is correct |
7 | Correct | 11 ms | 344 KB | Output is correct |
8 | Correct | 20 ms | 344 KB | Output is correct |
9 | Correct | 27 ms | 344 KB | Output is correct |
10 | Correct | 42 ms | 700 KB | Output is correct |
11 | Correct | 44 ms | 444 KB | Output is correct |
12 | Correct | 45 ms | 440 KB | Output is correct |
13 | Correct | 47 ms | 604 KB | Output is correct |
14 | Correct | 9 ms | 344 KB | Output is correct |
15 | Correct | 7 ms | 344 KB | Output is correct |
16 | Correct | 13 ms | 344 KB | Output is correct |
17 | Correct | 15 ms | 344 KB | Output is correct |
18 | Correct | 20 ms | 344 KB | Output is correct |
19 | Correct | 27 ms | 684 KB | Output is correct |
20 | Correct | 28 ms | 340 KB | Output is correct |
21 | Correct | 49 ms | 448 KB | Output is correct |
22 | Correct | 48 ms | 444 KB | Output is correct |
23 | Correct | 49 ms | 444 KB | Output is correct |
24 | Correct | 44 ms | 448 KB | Output is correct |
25 | Correct | 8 ms | 344 KB | Output is correct |
26 | Correct | 8 ms | 344 KB | Output is correct |
27 | Correct | 15 ms | 596 KB | Output is correct |
28 | Correct | 13 ms | 344 KB | Output is correct |
29 | Correct | 12 ms | 344 KB | Output is correct |
30 | Correct | 23 ms | 504 KB | Output is correct |
31 | Correct | 21 ms | 432 KB | Output is correct |
32 | Correct | 17 ms | 344 KB | Output is correct |
33 | Correct | 27 ms | 344 KB | Output is correct |
34 | Correct | 28 ms | 344 KB | Output is correct |
35 | Correct | 27 ms | 344 KB | Output is correct |
36 | Correct | 43 ms | 444 KB | Output is correct |
37 | Correct | 51 ms | 692 KB | Output is correct |
38 | Correct | 43 ms | 440 KB | Output is correct |
39 | Correct | 44 ms | 444 KB | Output is correct |
40 | Correct | 44 ms | 440 KB | Output is correct |
41 | Correct | 42 ms | 696 KB | Output is correct |
42 | Correct | 44 ms | 688 KB | Output is correct |
43 | Correct | 37 ms | 444 KB | Output is correct |
44 | Correct | 42 ms | 440 KB | Output is correct |
45 | Correct | 7 ms | 344 KB | Output is correct |
46 | Correct | 7 ms | 344 KB | Output is correct |
47 | Correct | 12 ms | 344 KB | Output is correct |
48 | Correct | 13 ms | 344 KB | Output is correct |
49 | Correct | 13 ms | 344 KB | Output is correct |
50 | Correct | 22 ms | 344 KB | Output is correct |
51 | Correct | 22 ms | 436 KB | Output is correct |
52 | Correct | 22 ms | 344 KB | Output is correct |
53 | Correct | 22 ms | 344 KB | Output is correct |
54 | Correct | 23 ms | 600 KB | Output is correct |
55 | Correct | 31 ms | 344 KB | Output is correct |
56 | Correct | 51 ms | 436 KB | Output is correct |
57 | Correct | 44 ms | 440 KB | Output is correct |
58 | Correct | 41 ms | 464 KB | Output is correct |
59 | Correct | 52 ms | 680 KB | Output is correct |
60 | Correct | 51 ms | 444 KB | Output is correct |
61 | Correct | 41 ms | 696 KB | Output is correct |
62 | Correct | 51 ms | 696 KB | Output is correct |
63 | Correct | 43 ms | 444 KB | Output is correct |
64 | Correct | 55 ms | 432 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 344 KB | Output is correct |
2 | Correct | 10 ms | 344 KB | Output is correct |
3 | Correct | 24 ms | 344 KB | Output is correct |
4 | Partially correct | 30 ms | 344 KB | Output is partially correct |
5 | Partially correct | 49 ms | 444 KB | Output is partially correct |
6 | Incorrect | 0 ms | 344 KB | Incorrect |
7 | Halted | 0 ms | 0 KB | - |