#pragma GCC diagnostic warning "-std=c++11"
#include <bits/stdc++.h>
#include "longesttrip.h"
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define flush fflush(stdout)
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pii pair<int,int>
using namespace std;
int n,m,T,k;
vector<int> longest_trip(int N, int D) {
vector<int> v;
int e[N][N];
for (int i=0; i<N; i++) {
for (int j=0; j<N; j++) {
e[i][j]=0;
}
}
vector<int> v1,v2;
for (int i=0; i<N; i++) {
for (int j=i+1; j<N; j++) {
vector<int> a,b; a.pb(i); b.pb(j);
if (are_connected(a,b)) {
e[i][j]=1; e[j][i]=1;
}
}
}
int cur=0,mx=0; v.pb(cur);
int l=0,r=-1;
for (int i=1; i<N; i++) {
if (e[cur][i]) {
v.pb(i);
if (i-cur>1) {
l=mx+1;r=i-1;
}
cur=i; mx=i;
int check=-1;
for (int j=l; j<=r; j++) {
if (e[i][j]) check=j;
}
if (check!=-1) {
v.pb(check);
for (int j=l; j<=r; j++) {
if (j!=check) v.pb(j);
}
cur=v.back();
l=0; r=-1;
}
}
}
if (cur!=N-1) {
l=cur+1; r=N-1;
}
if (r-l+1>N/2) {
vector<int> v2;
for (int i=l; i<=r; i++) v2.pb(i);
return v2;
}
return v;
}
Compilation message
longesttrip.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
1 | #pragma GCC diagnostic warning "-std=c++11"
| ^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
167 ms |
672 KB |
Incorrect |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
344 KB |
Output is correct |
2 |
Correct |
19 ms |
344 KB |
Output is correct |
3 |
Correct |
113 ms |
344 KB |
Output is correct |
4 |
Correct |
355 ms |
344 KB |
Output is correct |
5 |
Correct |
670 ms |
664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
344 KB |
Output is correct |
2 |
Correct |
24 ms |
344 KB |
Output is correct |
3 |
Correct |
121 ms |
344 KB |
Output is correct |
4 |
Correct |
345 ms |
344 KB |
Output is correct |
5 |
Correct |
712 ms |
664 KB |
Output is correct |
6 |
Incorrect |
0 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
344 KB |
Output is correct |
2 |
Correct |
26 ms |
344 KB |
Output is correct |
3 |
Correct |
135 ms |
344 KB |
Output is correct |
4 |
Correct |
330 ms |
344 KB |
Output is correct |
5 |
Correct |
720 ms |
668 KB |
Output is correct |
6 |
Correct |
7 ms |
344 KB |
Output is correct |
7 |
Correct |
22 ms |
344 KB |
Output is correct |
8 |
Correct |
126 ms |
344 KB |
Output is correct |
9 |
Correct |
267 ms |
596 KB |
Output is correct |
10 |
Correct |
768 ms |
664 KB |
Output is correct |
11 |
Correct |
762 ms |
664 KB |
Output is correct |
12 |
Correct |
750 ms |
664 KB |
Output is correct |
13 |
Correct |
726 ms |
668 KB |
Output is correct |
14 |
Correct |
8 ms |
344 KB |
Output is correct |
15 |
Correct |
12 ms |
344 KB |
Output is correct |
16 |
Correct |
42 ms |
344 KB |
Output is correct |
17 |
Correct |
73 ms |
344 KB |
Output is correct |
18 |
Correct |
126 ms |
344 KB |
Output is correct |
19 |
Correct |
268 ms |
344 KB |
Output is correct |
20 |
Correct |
269 ms |
344 KB |
Output is correct |
21 |
Correct |
766 ms |
668 KB |
Output is correct |
22 |
Correct |
747 ms |
664 KB |
Output is correct |
23 |
Correct |
755 ms |
664 KB |
Output is correct |
24 |
Correct |
697 ms |
848 KB |
Output is correct |
25 |
Correct |
9 ms |
344 KB |
Output is correct |
26 |
Correct |
8 ms |
344 KB |
Output is correct |
27 |
Correct |
21 ms |
344 KB |
Output is correct |
28 |
Correct |
22 ms |
344 KB |
Output is correct |
29 |
Correct |
25 ms |
344 KB |
Output is correct |
30 |
Correct |
153 ms |
344 KB |
Output is correct |
31 |
Incorrect |
27 ms |
344 KB |
Incorrect |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
588 KB |
Output is correct |
2 |
Correct |
26 ms |
344 KB |
Output is correct |
3 |
Partially correct |
119 ms |
344 KB |
Output is partially correct |
4 |
Partially correct |
353 ms |
344 KB |
Output is partially correct |
5 |
Partially correct |
712 ms |
668 KB |
Output is partially correct |
6 |
Incorrect |
0 ms |
344 KB |
Incorrect |
7 |
Halted |
0 ms |
0 KB |
- |