제출 #1118563

#제출 시각아이디문제언어결과실행 시간메모리
1118563ElayV13Table Tennis (info1cup20_tabletennis)C++17
34 / 100
3095 ms519716 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ld double const int INF = 1e18; const int mod = 12345; const int sz = 1e6 + 5; int n , k; void solve() { cin >> n >> k; n = n + k; vector < int > a(n); for(int i = 0;i < n;i++) cin >> a[i]; sort(a.begin() , a.end()); for(int bit = 0;bit <= pow(2 , n) - 1;bit++) { vector < int > q1; vector < int > q2; for(int i = 0;i < n;i++) { if((1 << i) & bit) q1.push_back(a[i]); else q2.push_back(a[i]); } if(q1.size() != k) continue; set < int > v; for(int i = 0;i < q2.size() / 2;i++) { v.insert(q2[i] + q2[q2.size() - i - 1]); } if(v.size() == 1) { for(int i : q2) { cout << i << ' '; } return; } } } signed main() { ios_base::sync_with_stdio(0);cin.tie(0); if(k == 1) { solve(); return 0; } cin >> n >> k; vector < int > a(n + k); map < int , int > cnt; for(int i = 0;i < n + k;i++) { cin >> a[i]; cnt[a[i]]++; } sort(a.begin() , a.end()); int ls = (n / 2); map < int , int > m; int pos = -1; for(int i = 0;i < n + k - 1;i++) { bool f = 0; for(int j = i + 1;j < n + k;j++) { if(a[j] == a[j - 1]) continue; m[a[i] + a[j]]++; if(m[a[i] + a[j]] == ls) { f = 1; pos = a[i] + a[j]; break; } } if(f) break; } vector < pair < int , int > > ans; for(int i = 0;i < n;i++) { if(ans.size() == n / 2) break; if(cnt[pos - a[i]] > 0) ans.push_back({a[i] , pos - a[i]}); } vector < int > anss; for(int i = 0;i < ans.size();i++) { anss.push_back(ans[i].first); anss.push_back(ans[i].second); } sort(anss.begin() , anss.end()); for(int i : anss) cout << i << ' '; //cout << pos << endl; }

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

tabletennis.cpp: In function 'void solve()':
tabletennis.cpp:30:20: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   30 |       if(q1.size() != k) continue;
      |          ~~~~~~~~~~^~~~
tabletennis.cpp:32:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |       for(int i = 0;i < q2.size() / 2;i++)
      |                     ~~^~~~~~~~~~~~~~~
tabletennis.cpp: In function 'int main()':
tabletennis.cpp:86:21: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   86 |       if(ans.size() == n / 2) break;
      |          ~~~~~~~~~~~^~~~~~~~
tabletennis.cpp:90:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |    for(int i = 0;i < ans.size();i++)
      |                  ~~^~~~~~~~~~~~
#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...