제출 #533243

#제출 시각아이디문제언어결과실행 시간메모리
533243hhhhauraTable Tennis (info1cup20_tabletennis)C++14
100 / 100
291 ms33744 KiB
#define wiwihorz #include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("sse") #pragma loop-opt(on) #define rep(i, a, b) for(int i = a; i <= b; i ++) #define rrep(i, a, b) for(int i = b; i >= a; i--) #define ceil(a, b) ((a + b - 1) / (b)) #define all(x) x.begin(), x.end() #define lld long double #define pii pair<int, int> #define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()) using namespace std; #define INF 1000000000000000000 #define MOD 1000000007 #define eps (1e-9) #ifdef wiwihorz #define print(a...) cerr<<"Line "<<__LINE__<<":",kout("[" + string(#a) + "] = ", a) void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L)==R], ++L;} void kout() { cerr << endl; } template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...);} #else #define print(...) 0 #define vprint(...) 0 #endif #define x first #define y second signed main() { ios::sync_with_stdio(false), cin.tie(0); int n, k; cin >> n >> k; vector<int> a(n + k + 1, 0); rep(i, 1, n + k) cin >> a[i]; auto solve = [&](int val) { vector<int> ans; int l = 1, r = n + k, cost = k; rep(i, l, r) { while(r - 1 > i && a[r] > val - a[i]) r--, cost--; if(a[i] + a[r] == val) { ans.push_back(a[i]); ans.push_back(a[r]); r --; } else cost --; } if(cost < 0 || ans.size() < n) return vector<int>(); while(ans.size() > n) ans.pop_back(); sort(all(ans)); return ans; }; if(n + k < 4 * k) { rep(i, 0, k) rep(j, 0, k - i) { int val = a[i + 1] + a[n + k - j]; vector<int> ans = solve(val); if(ans.size() == n) { rep(cur, 0, n - 1) cout << ans[cur] << " \n"[cur + 1 == n]; return 0; } } } else { map<int, int> cnt; rep(i, 1, 2 * k) rep(j, n - k + 1, n + k) cnt[a[i] + a[j]] ++; for(auto i : cnt) if(i.y >= k) { vector<int> ans = solve(i.x); if(ans.size() == n) { rep(cur, 0, n - 1) cout << ans[cur] << " \n"[cur + 1 == n]; return 0; } } } assert(0); return 0; }

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

tabletennis.cpp:5: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    5 | #pragma loop-opt(on)
      | 
tabletennis.cpp:20:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   20 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L)==R], ++L;}
      |             ^~~~
tabletennis.cpp:20:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   20 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L)==R], ++L;}
      |                     ^~~~
tabletennis.cpp: In lambda function:
tabletennis.cpp:48:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |   if(cost < 0 || ans.size() < n) return vector<int>();
      |                  ~~~~~~~~~~~^~~
tabletennis.cpp:49:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   49 |   while(ans.size() > n) ans.pop_back();
      |         ~~~~~~~~~~~^~~
tabletennis.cpp: In function 'int main()':
tabletennis.cpp:57:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |    if(ans.size() == n) {
      |       ~~~~~~~~~~~^~~~
tabletennis.cpp:68:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   68 |    if(ans.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...