제출 #1229461

#제출 시각아이디문제언어결과실행 시간메모리
1229461radodododoTriangles (CEOI18_tri)C++20
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> #include <random> using namespace std; #ifdef __cplusplus extern "C" { #endif int get_n(); int is_clockwise(int a, int b, int c); void give_answer(int s); #ifdef __cplusplus } #endif mt19937_64 ggg; long long ccin_n() { return get_n(); /*long long zzz; cin >> zzz; return zzz;*/ } vector<long long> reall; bool aski(long long a, long long b, long long c) { return is_clockwise(reall[a] + 1, reall[b] + 1, reall[c] + 1); /*cout << "? " << a << " " << b << " " << c << '\n'; bool okak; cin >> okak; return okak;*/ } bool cmpp(long long a, long long b) { if (a == 0) { return true; } if (a == 1) { return a < b; } if (b == 0) { return false; } if (b == 1) { return a < b; } bool aska = aski(1, 0, a); bool askb = aski(1, 0, b); if (aska && !askb) { return true; } if (!aska && askb) { return false; } return aski(a, 0, b); } void say_anse(long long x) { give_answer(x); //cout << "! " << x; } int main() { long long n = ccin_n(); vector<long long> srt(n); for (long long i = 0; i < n; i++) { srt[i] = i; } reall = srt; random_shuffle(reall.begin(), reall.end(), ggg); sort(srt.begin(), srt.end(), cmpp); long long ii = -1; for (long long i = 1; i + 1 < n; i++) { if (aski(0, srt[i], srt[i + 1])) { ii = i + 1; break; } } if (ii == -1) { vector<long long> ch; for (auto i : srt) { if (ch.size() < 2) { ch.push_back(i); continue; } while (ch.size() >= 2 && aski(ch[ch.size() - 2], ch.back(), i)) { ch.pop_back(); } ch.push_back(i); } vector<long long> sv = ch; vector<bool> delet(n); for (auto i : srt) { if (ch.size() < 2) { ch.push_back(i); continue; } while (ch.size() >= 2 && aski(ch[ch.size() - 2], ch.back(), i)) { delet[ch.back()] = 1; ch.pop_back(); } ch.push_back(i); } long long ans = sv.size(); for (auto x : sv) { if (delet[x]) { ans--; } } say_anse(ans); } else { vector<long long> newsrt = { 0 }; for (long long j = ii; j < n; j++) { newsrt.push_back(srt[j]); } for (long long j = 1; j < ii; j++) { newsrt.push_back(srt[j]); } //cout << ii << " " << srt[ii] << '\n'; srt = newsrt; /*for (auto gh : srt) { cout << gh << " "; } cout << '\n';*/ vector<long long> ch; for (auto i : srt) { if (ch.size() < 2) { ch.push_back(i); continue; } while (ch.size() >= 2 && aski(ch[ch.size() - 2], ch.back(), i)) { ch.pop_back(); } ch.push_back(i); } /*for (auto gh : ch) { cout << gh << " "; } cout << '\n';*/ say_anse(ch.size()); } }

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

In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from tri.cpp:1:
/usr/include/c++/11/bits/stl_algo.h: In instantiation of 'void std::random_shuffle(_RAIter, _RAIter, _Generator&&) [with _RAIter = __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >; _Generator = std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>&]':
tri.cpp:74:16:   required from here
/usr/include/c++/11/bits/stl_algo.h:4619:55: error: no match for call to '(std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>) (__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type)'
 4619 |           _RandomAccessIterator __j = __first + __rand((__i - __first) + 1);
      |                                                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/random:51,
                 from tri.cpp:4:
/usr/include/c++/11/bits/random.tcc:450:5: note: candidate: 'std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::operator()() [with _UIntType = long unsigned int; long unsigned int __w = 64; long unsigned int __n = 312; long unsigned int __m = 156; long unsigned int __r = 31; _UIntType __a = 13043109905998158313; long unsigned int __u = 29; _UIntType __d = 6148914691236517205; long unsigned int __s = 17; _UIntType __b = 8202884508482404352; long unsigned int __t = 37; _UIntType __c = 18444473444759240704; long unsigned int __l = 43; _UIntType __f = 6364136223846793005; std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type = long unsigned int]'
  450 |     mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  451 |                             __s, __b, __t, __c, __l, __f>::
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/random.tcc:450:5: note:   candidate expects 0 arguments, 1 provided