#include "longesttrip.h"
#include <bits/stdc++.h>
#define rep(a,b,c) for(int a=b; a<c; a++)
#define repa(a,b) for(auto a:b)
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define pf push_front
#define fi first
#define se second
using namespace std;
vector<int> longest_trip(int N, int D){
deque<vector<int>> ans;
rep(i,0,N){
ans.pb({i});
}
while(ans.size()>1){
if(are_connected({ans[0].back()},{ans[1].back()})){
repa(e,ans[1]) ans[0].pb(e);
ans.erase(ans.begin()+1);
}else if(are_connected({ans[0].back()},{ans[2].back()})){
repa(e,ans[2]) ans[0].pb(e);
ans.erase(ans.begin()+2);
}else{
repa(e,ans[2]) ans[1].pb(e);
ans.erase(ans.begin()+2);
}
}
if(ans[0].size()>ans[1].size()) return ans[0];
else return ans[1];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
invalid array |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
7 ms |
596 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 |
456 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 |
4 ms |
344 KB |
Output is correct |
4 |
Correct |
5 ms |
344 KB |
Output is correct |
5 |
Correct |
5 ms |
600 KB |
Output is correct |
6 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 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 |
5 ms |
344 KB |
Output is correct |
5 |
Correct |
5 ms |
448 KB |
Output is correct |
6 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 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 |
6 ms |
344 KB |
Output is correct |
5 |
Correct |
4 ms |
456 KB |
Output is correct |
6 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
7 |
Halted |
0 ms |
0 KB |
- |