Submission #247389

#TimeUsernameProblemLanguageResultExecution timeMemory
247389_ash__Sticks (POI11_pat)C++14
100 / 100
371 ms22340 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 100; int main() { // freopen("in.txt", "r", stdin); ios::sync_with_stdio(0); cin.tie(0); int K; cin >> K; vector<vector<int>> col(K); vector<pair<int,int>> all; for(int i = 0; i < K; i++) { int n; cin >> n; while(n--) { int x; cin >> x; col[i].push_back(x); all.push_back({x, i}); } sort(col[i].begin(), col[i].end()); } sort(all.begin(), all.end()); vector<int> best(K); for(int i = 0; i < all.size(); i++) { int a = 0, b = 0, col_a, col_b; int col_c = all[i].second; for(int j = 0; j < K; j++) { if(col_c == j) continue; int x = best[j]; if(x > b) a = b, col_a = col_b, b = x, col_b = j; else if(x > a) col_a = j, a = x; } int c = all[i].first; if(a+b > c) { cout << col_a+1 << " " << a << " " << col_b+1 << " " << b << " " << col_c+1 << " " << c << endl; exit(0); } best[col_c] = c; } cout << "NIE" << endl; return 0; }

Compilation message (stderr)

pat.cpp: In function 'int main()':
pat.cpp:28:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < all.size(); i++) {
                    ~~^~~~~~~~~~~~
pat.cpp:39:32: warning: 'col_a' may be used uninitialized in this function [-Wmaybe-uninitialized]
             cout << col_a+1 << " " << a << " " << col_b+1 << " " << b << " " << col_c+1 << " " << c << endl;
                                ^~~
pat.cpp:39:62: warning: 'col_b' may be used uninitialized in this function [-Wmaybe-uninitialized]
             cout << col_a+1 << " " << a << " " << col_b+1 << " " << b << " " << col_c+1 << " " << c << 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...
#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...