Submission #717301

#TimeUsernameProblemLanguageResultExecution timeMemory
717301vjudge1Table Tennis (info1cup20_tabletennis)C++17
0 / 100
46 ms3532 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl '\n' const int M = 2e5+5, MOD = 998244353; int v[M], ind[M]; signed main() { cin.tie(0)->sync_with_stdio(0); int n, k; cin >> n >> k; n += k; for (int i = 1; i <= n; i++) cin >> v[i]; for (int i = 1; i <= n; i++) ind[i] = i; sort(ind+1, ind+n+1, [](int a, int b) {return v[a] < v[b];}); sort(v+1, v+n+1); map<int, int> fr; for (int i = 1; i < n; i++) fr[v[i+1]-v[i]]++; int ans; for (int i = 1; i <= n; i++) { if (i > 1) {fr[v[i]-v[i-1]]--; if (!fr[v[i]-v[i-1]]) fr.erase(v[i]-v[i-1]);} if (i < n) {fr[v[i+1]-v[i]]--; if (!fr[v[i+1]-v[i]]) fr.erase(v[i+1]-v[i]);} if (i > 1 && i < n) fr[v[i+1]-v[i-1]]++; if (fr.size() == 1) ans = ind[i]; if (i > 1) fr[v[i]-v[i-1]]++; if (i < n) fr[v[i+1]-v[i]]++; if (i > 1 && i < n) {fr[v[i+1]-v[i-1]]--; if (!fr[v[i+1]-v[i-1]]) fr.erase(v[i+1]-v[i-1]);}; } for (int i = 1; i <= n; i++) if (i != ans) cout << i << ' '; cout << endl; return 0; } /* 4 3 1 2 3 4 8 10 20 */

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:37:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   37 |     for (int i = 1; i <= n; i++) if (i != ans) cout << i << ' '; cout << endl;
      |     ^~~
tabletennis.cpp:37:66: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   37 |     for (int i = 1; i <= n; i++) if (i != ans) cout << i << ' '; cout << endl;
      |                                                                  ^~~~
tabletennis.cpp:37:34: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   37 |     for (int i = 1; i <= n; i++) if (i != ans) cout << i << ' '; cout << endl;
      |                                  ^~
#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...