제출 #1161096

#제출 시각아이디문제언어결과실행 시간메모리
1161096steveonalex가장 긴 여행 (IOI23_longesttrip)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define MASK(i) (1ULL << (i)) #define GETBIT(mask, i) (((mask) >> (i)) & 1) #define ALL(v) (v).begin(), (v).end() ll max(ll a, ll b){return (a > b) ? a : b;} ll min(ll a, ll b){return (a < b) ? a : b;} ll gcd(ll a, ll b){return __gcd(a, b);} ll lcm(ll a, ll b){return a / gcd(a, b) * b;} ll LASTBIT(ll mask){return (mask) & (-mask);} int pop_cnt(ull mask){return __builtin_popcountll(mask);} int ctz(ull mask){return __builtin_ctzll(mask);} int logOf(ull mask){return 63 - __builtin_clzll(mask);} //mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); mt19937_64 rng(1); ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);} double rngesus_d(double l, double r){ double wow = (double) ((ull) rng()) / ((ull)(0-1)); return wow * (r - l) + l; } template <class T1, class T2> bool maximize(T1 &a, T2 b){ if (a < b) {a = b; return true;} return false; } template <class T1, class T2> bool minimize(T1 &a, T2 b){ if (a > b) {a = b; return true;} return false; } template <class T> void printArr(T container, string separator = " ", string finish = "\n", ostream &out = cout){ for(auto item: container) out << item << separator; out << finish; } template <class T> void remove_dup(vector<T> &a){ sort(ALL(a)); a.resize(unique(ALL(a)) - a.begin()); } #include "longesttrip.h" vector<int> longest_trip(int n, int d){ vector<int> S1, S2; S1.push_back(0); for(int i = 1; i < n; ++i){ if (S2.size()){ vector<int> A = {S1.back()}, B = {S2.back()}, C = {i}; bool c1 = are_connected(A, C), c2 = are_connected(B, C); if (c1 && c2){ S1.push_back(i); while(S2.size()){ S1.push_back(S2.back()); S2.pop_back(); } } else if (c1){ S1.push_back(i); } else if (c2){ S2.push_back(i); } else assert(false); } else{ if (are_connected({S1.back()}, {i})) S1.push_back(i); else S2.push_back(i); } } if (S1.size() < S2.size()) swap(S1, S2); if (S2.empty()) return S1; if (!are_connected(S1, S2)) return S1; if (!are_connected({S1[0], S1.back()})){ if (are_connected({S1.back()}, {S2[0]})){ for(int i: S2) S1.push_back(i); return S1; } else{ reverse(ALL(S1)); for(int i: S2) S1.push_back(i); return S1; } } if (!are_connected({S2[0], S2.back()})){ swap(S1, S2); if (are_connected({S1.back()}, {S2[0]})){ for(int i: S2) S1.push_back(i); return S1; } else{ reverse(ALL(S1)); for(int i: S2) S1.push_back(i); return S1; } } return S1; }

컴파일 시 표준 에러 (stderr) 메시지

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:87:23: error: too few arguments to function 'bool are_connected(std::vector<int>, std::vector<int>)'
   87 |     if (!are_connected({S1[0], S1.back()})){
      |          ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from longesttrip.cpp:53:
longesttrip.h:5:6: note: declared here
    5 | bool are_connected(std::vector<int> A, std::vector<int> B);
      |      ^~~~~~~~~~~~~
longesttrip.cpp:98:23: error: too few arguments to function 'bool are_connected(std::vector<int>, std::vector<int>)'
   98 |     if (!are_connected({S2[0], S2.back()})){
      |          ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from longesttrip.cpp:53:
longesttrip.h:5:6: note: declared here
    5 | bool are_connected(std::vector<int> A, std::vector<int> B);
      |      ^~~~~~~~~~~~~