Submission #667641

#TimeUsernameProblemLanguageResultExecution timeMemory
667641pedroslreyTable Tennis (info1cup20_tabletennis)C++14
35 / 100
3117 ms721992 KiB
#include <bits/stdc++.h> using namespace std; map<int, int> vals; bool test(vector<int> &xs, int n, int k, int x) { vector<int> marc(n + k); vector<int> pairs; for (int i = 0; i < n + k; ++i) if (!marc[i+1] && vals[x - xs[i]] != 0 && vals[x - xs[i]] != i + 1) { pairs.push_back(xs[i]); pairs.push_back(x - xs[i]); marc[vals[x - xs[i]]] = true; } sort(pairs.begin(), pairs.end()); if (pairs.size() >= n) { for (int i = 0; i < n; ++i) cout << pairs[i] << " "; cout << "\n"; return true; } return false; } int main() { int n, k; cin >> n >> k; vector<int> xs(n+k); for (int &x: xs) cin >> x; for (int i = 0; i < n + k; ++i) vals[xs[i]] = i + 1; for (int i = 0; i < n + k; ++i) for (int j = i+1; j < n + k; ++j) if (test(xs, n, k, xs[i] + xs[j])) return 0; }

Compilation message (stderr)

tabletennis.cpp: In function 'bool test(std::vector<int>&, int, int, int)':
tabletennis.cpp:19:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |     if (pairs.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...