답안 #839813

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
839813 2023-08-30T17:04:49 Z AdamGS 가장 긴 여행 (IOI23_longesttrip) C++17
60 / 100
603 ms 336 KB
#include "longesttrip.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
vector<int>longest_trip(int n, int d) {
  vector<int>A, B;
  A.pb(0);
  for(int i=1; i<n; ++i) {
    vector<int>X, Y;
    X.pb(A.back());
    Y.pb(i);
    if(are_connected(X, Y)) A.pb(i);
    else B.pb(i);
    X.clear();
    Y.clear();
    if(B.size()>0) {
      X.pb(A.back());
      Y.pb(B.back());
      if(are_connected(X, Y)) while(B.size()>0) {
        A.pb(B.back());
        B.pop_back();
      }
    }
  }
  if(B.size()>A.size()) swap(A, B);
  if(B.size()==0) return A;
  vector<int>X, Y;
  X.pb(A[0]);
  Y.pb(B[0]);
  if(are_connected(X, Y)) {
    reverse(all(A));
    for(auto i : B) A.pb(i);
    return A;
  }
  Y.clear();
  Y.pb(B.back());
  if(are_connected(X, Y)) {
    for(auto i : A) B.pb(i);
    return B;
  }
  X.clear();
  Y.clear();
  X.pb(A.back());
  Y.pb(B[0]);
  if(are_connected(X, Y)) {
    for(auto i : B) A.pb(i);
    return A;
  }
  rep(i, A.size()) rep(j, B.size()) {
    X.clear();
    Y.clear();
    X.pb(A[i]);
    Y.pb(B[j]);
    if(are_connected(X, Y)) {
      vector<int>ans;
      rep(l, A.size()) ans.pb(A[(i+l+1)%A.size()]);
      rep(l, B.size()) ans.pb(B[(j+l)%B.size()]);
      return ans;
    }
  }
  return A;
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:4:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
longesttrip.cpp:53:3: note: in expansion of macro 'rep'
   53 |   rep(i, A.size()) rep(j, B.size()) {
      |   ^~~
longesttrip.cpp:4:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
longesttrip.cpp:53:20: note: in expansion of macro 'rep'
   53 |   rep(i, A.size()) rep(j, B.size()) {
      |                    ^~~
longesttrip.cpp:4:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
longesttrip.cpp:60:7: note: in expansion of macro 'rep'
   60 |       rep(l, A.size()) ans.pb(A[(i+l+1)%A.size()]);
      |       ^~~
longesttrip.cpp:4:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
longesttrip.cpp:61:7: note: in expansion of macro 'rep'
   61 |       rep(l, B.size()) ans.pb(B[(j+l)%B.size()]);
      |       ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 3 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 8 ms 208 KB Output is correct
5 Correct 10 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 6 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 10 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
8 Correct 10 ms 208 KB Output is correct
9 Correct 9 ms 208 KB Output is correct
10 Correct 6 ms 208 KB Output is correct
11 Correct 7 ms 208 KB Output is correct
12 Correct 8 ms 208 KB Output is correct
13 Correct 10 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 208 KB Output is correct
2 Correct 10 ms 208 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 10 ms 208 KB Output is correct
5 Correct 9 ms 208 KB Output is correct
6 Correct 12 ms 208 KB Output is correct
7 Correct 11 ms 208 KB Output is correct
8 Correct 10 ms 208 KB Output is correct
9 Correct 10 ms 208 KB Output is correct
10 Correct 8 ms 208 KB Output is correct
11 Correct 11 ms 208 KB Output is correct
12 Correct 9 ms 208 KB Output is correct
13 Correct 6 ms 208 KB Output is correct
14 Correct 28 ms 208 KB Output is correct
15 Correct 31 ms 208 KB Output is correct
16 Correct 17 ms 208 KB Output is correct
17 Correct 12 ms 208 KB Output is correct
18 Correct 12 ms 208 KB Output is correct
19 Correct 8 ms 208 KB Output is correct
20 Correct 8 ms 208 KB Output is correct
21 Correct 12 ms 208 KB Output is correct
22 Correct 12 ms 208 KB Output is correct
23 Correct 11 ms 208 KB Output is correct
24 Correct 11 ms 208 KB Output is correct
25 Correct 20 ms 208 KB Output is correct
26 Correct 32 ms 208 KB Output is correct
27 Correct 11 ms 208 KB Output is correct
28 Correct 24 ms 208 KB Output is correct
29 Correct 16 ms 208 KB Output is correct
30 Correct 22 ms 208 KB Output is correct
31 Correct 123 ms 208 KB Output is correct
32 Correct 112 ms 208 KB Output is correct
33 Correct 31 ms 208 KB Output is correct
34 Correct 41 ms 208 KB Output is correct
35 Correct 50 ms 208 KB Output is correct
36 Correct 15 ms 300 KB Output is correct
37 Correct 78 ms 208 KB Output is correct
38 Correct 172 ms 208 KB Output is correct
39 Correct 324 ms 208 KB Output is correct
40 Correct 401 ms 208 KB Output is correct
41 Correct 512 ms 208 KB Output is correct
42 Correct 594 ms 208 KB Output is correct
43 Correct 398 ms 208 KB Output is correct
44 Correct 423 ms 296 KB Output is correct
45 Correct 7 ms 208 KB Output is correct
46 Correct 14 ms 208 KB Output is correct
47 Correct 13 ms 208 KB Output is correct
48 Correct 8 ms 208 KB Output is correct
49 Correct 10 ms 208 KB Output is correct
50 Correct 11 ms 208 KB Output is correct
51 Correct 80 ms 208 KB Output is correct
52 Correct 73 ms 208 KB Output is correct
53 Correct 17 ms 280 KB Output is correct
54 Correct 21 ms 296 KB Output is correct
55 Correct 24 ms 276 KB Output is correct
56 Correct 13 ms 208 KB Output is correct
57 Correct 32 ms 208 KB Output is correct
58 Correct 178 ms 300 KB Output is correct
59 Correct 389 ms 300 KB Output is correct
60 Correct 249 ms 208 KB Output is correct
61 Correct 91 ms 208 KB Output is correct
62 Correct 315 ms 208 KB Output is correct
63 Correct 228 ms 208 KB Output is correct
64 Correct 284 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 10 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 8 ms 208 KB Output is correct
5 Correct 10 ms 208 KB Output is correct
6 Correct 12 ms 208 KB Output is correct
7 Correct 11 ms 208 KB Output is correct
8 Correct 8 ms 208 KB Output is correct
9 Correct 8 ms 208 KB Output is correct
10 Correct 9 ms 208 KB Output is correct
11 Correct 8 ms 292 KB Output is correct
12 Correct 7 ms 208 KB Output is correct
13 Correct 9 ms 208 KB Output is correct
14 Correct 30 ms 208 KB Output is correct
15 Correct 20 ms 208 KB Output is correct
16 Correct 11 ms 208 KB Output is correct
17 Correct 7 ms 208 KB Output is correct
18 Correct 10 ms 208 KB Output is correct
19 Correct 10 ms 208 KB Output is correct
20 Correct 9 ms 208 KB Output is correct
21 Correct 26 ms 208 KB Output is correct
22 Correct 24 ms 208 KB Output is correct
23 Correct 27 ms 208 KB Output is correct
24 Correct 18 ms 208 KB Output is correct
25 Correct 18 ms 208 KB Output is correct
26 Correct 26 ms 208 KB Output is correct
27 Partially correct 119 ms 208 KB Output is partially correct
28 Partially correct 166 ms 208 KB Output is partially correct
29 Correct 17 ms 208 KB Output is correct
30 Partially correct 25 ms 208 KB Output is partially correct
31 Partially correct 48 ms 208 KB Output is partially correct
32 Correct 14 ms 208 KB Output is correct
33 Correct 15 ms 208 KB Output is correct
34 Correct 14 ms 208 KB Output is correct
35 Correct 15 ms 208 KB Output is correct
36 Correct 16 ms 208 KB Output is correct
37 Correct 16 ms 208 KB Output is correct
38 Partially correct 53 ms 208 KB Output is partially correct
39 Partially correct 64 ms 208 KB Output is partially correct
40 Correct 10 ms 208 KB Output is correct
41 Partially correct 25 ms 300 KB Output is partially correct
42 Partially correct 20 ms 280 KB Output is partially correct
43 Correct 10 ms 208 KB Output is correct
44 Correct 12 ms 208 KB Output is correct
45 Correct 11 ms 208 KB Output is correct
46 Correct 9 ms 300 KB Output is correct
47 Partially correct 23 ms 208 KB Output is partially correct
48 Partially correct 73 ms 208 KB Output is partially correct
49 Partially correct 225 ms 208 KB Output is partially correct
50 Partially correct 430 ms 208 KB Output is partially correct
51 Partially correct 421 ms 300 KB Output is partially correct
52 Partially correct 584 ms 208 KB Output is partially correct
53 Partially correct 603 ms 300 KB Output is partially correct
54 Partially correct 406 ms 208 KB Output is partially correct
55 Partially correct 561 ms 208 KB Output is partially correct
56 Partially correct 106 ms 208 KB Output is partially correct
57 Partially correct 319 ms 208 KB Output is partially correct
58 Partially correct 361 ms 304 KB Output is partially correct
59 Partially correct 550 ms 208 KB Output is partially correct
60 Partially correct 538 ms 208 KB Output is partially correct
61 Partially correct 479 ms 296 KB Output is partially correct
62 Partially correct 14 ms 296 KB Output is partially correct
63 Partially correct 24 ms 208 KB Output is partially correct
64 Partially correct 120 ms 208 KB Output is partially correct
65 Partially correct 377 ms 208 KB Output is partially correct
66 Partially correct 305 ms 208 KB Output is partially correct
67 Partially correct 115 ms 208 KB Output is partially correct
68 Partially correct 231 ms 208 KB Output is partially correct
69 Partially correct 320 ms 296 KB Output is partially correct
70 Partially correct 339 ms 208 KB Output is partially correct
71 Partially correct 37 ms 300 KB Output is partially correct
72 Partially correct 194 ms 300 KB Output is partially correct
73 Partially correct 146 ms 208 KB Output is partially correct
74 Partially correct 437 ms 208 KB Output is partially correct
75 Partially correct 254 ms 208 KB Output is partially correct
76 Partially correct 335 ms 208 KB Output is partially correct
77 Partially correct 45 ms 292 KB Output is partially correct
78 Partially correct 156 ms 208 KB Output is partially correct
79 Partially correct 119 ms 296 KB Output is partially correct
80 Partially correct 197 ms 208 KB Output is partially correct
81 Partially correct 276 ms 208 KB Output is partially correct
82 Partially correct 168 ms 208 KB Output is partially correct