제출 #387721

#제출 시각아이디문제언어결과실행 시간메모리
3877212qbingxuanTable Tennis (info1cup20_tabletennis)C++14
100 / 100
817 ms61872 KiB
#include <bits/stdc++.h> #ifdef local #define debug(a...) qqbx(#a, a) template <typename ...T> void qqbx(const char *s, T ...a) { int cnt = sizeof...(T); ((std::cerr << "\033[1;32m(" << s << ") = (") , ... , (std::cerr << a << (--cnt ? ", " : ")\033[0m\n"))); } #define pary(a...) danb(#a, a) template <typename T> void danb(const char *s, T L, T R) { std::cerr << "\033[1;32m[ " << s << " ] = [ "; for (int f = 0; L != R; ++L) std::cerr << (f++ ? " " : "") << *L; std::cerr << " ]\033[0m\n"; } #else #define debug(...) ((void)0) #define pary(...) ((void)0) #endif // local #define all(v) begin(v),end(v) #define pb emplace_back using namespace std; using ll = int64_t; const int inf = 1e9, MOD = 1000000007, maxn = 1 << 18, maxLg = 18; signed main() { ios_base::sync_with_stdio(0), cin.tie(0); int n, k; cin >> n >> k; int m = n+k; vector<int> a(m); for (int i = 0; i < m; i++) cin >> a[i]; int lim = min(m / 2, k * 2); vector<int> jizz(a.begin(), a.begin() + lim); jizz.insert(jizz.end(), a.end() - lim, a.end()); map<int,int> freq; for (int x: jizz) for (int y: jizz) if (x < y) ++freq[x+y]; for (auto [val, cnt]: freq) if (cnt >= min(n/2, k)) { debug(val); vector<int> cur; for (int i = 0, j = a.size()-1; i < j; i++) { while (j > i && a[j] > val - a[i]) --j; if (j > i && a[j] + a[i] == val) cur.pb(a[i]), cur.pb(a[j]); } if (cur.size() == n) { sort(all(cur)); for (int x: cur) cout << x << ' '; cout << '\n'; return 0; } } }

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

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:40:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   40 |     for (auto [val, cnt]: freq) if (cnt >= min(n/2, k)) {
      |               ^
tabletennis.cpp:48:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |         if (cur.size() == n) {
      |             ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...