Submission #313919

#TimeUsernameProblemLanguageResultExecution timeMemory
313919hoaphat1Sticks (POI11_pat)C++17
100 / 100
202 ms4260 KiB
#include<bits/stdc++.h> using namespace std; void fff(string s = "") { if (s == "1") cin >> s; if ((int)s.size() >= 4 && s.substr(s.size() - 4) == ".inp") { freopen(s.c_str(),"r",stdin); } } int main() { ios::sync_with_stdio(false); cin.tie(0); fff(""); int n; cin >> n; vector<vector<int>> a(n); for (int i = 0; i < n; i++) { int foo; cin >> foo; a[i].resize(foo); for (auto&x : a[i]) { cin >> x; } sort(a[i].begin(),a[i].end()); } for (int i = 0; i < n; i++) { vector<int> id(n,-1); for (auto&x : a[i]) { vector<pair<int,int>> b(2,make_pair(0,0)); for (int j = 0; j < n; j++) { if (i == j) continue; while (id[j] < (int)a[j].size() - 1 && a[j][id[j] + 1] <= x) id[j] += 1; if (id[j] != -1) { if (a[j][id[j]] >= b[0].first) { b[1] = b[0]; b[0] = make_pair(a[j][id[j]],j); } else if (a[j][id[j]] > b[1].first) { b[1] = make_pair(a[j][id[j]],j); } } } if ((int)b.size() == 2 && b[0].first + b[1].first > x) { cout << i + 1 <<" " << x <<" " << b[0].second + 1 <<" " << b[0].first <<" " << b[1].second + 1 <<" " << b[1].first; exit(0); } } } cout << "NIE"; }

Compilation message (stderr)

pat.cpp: In function 'void fff(std::string)':
pat.cpp:8:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
    8 |   freopen(s.c_str(),"r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...