Submission #234593

#TimeUsernameProblemLanguageResultExecution timeMemory
234593VimmerHokej (COCI17_hokej)C++14
96 / 120
1065 ms18296 KiB
#include <bits/stdc++.h> #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-O3") #pragma GCC optimize("Ofast") #define F first #define S second #define sz(x) int(x.size()) #define pb push_back #define N 500005 #define M ll(1e9 + 7) #define inf 1e9 + 1e9 using namespace std; typedef long double ld; typedef long long ll; typedef short int si; int main() { //freopen("input.txt", "r", stdin);// freopen("output.txt", "w", stdout); ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0); int m, n; cin >> m >> n; int a[m][6]; vector <pair <pair <int, int>, int> > g(n); for (int i = 0; i < n; i++) { g[i].S = i; cin >> g[i].F.F >> g[i].F.S; } sort(g.begin(), g.end()); reverse(g.begin(), g.end()); int j = 0, kol = 0; ll ans = 0; for (int u = 0; u < 6; u++) for (int i = 0; i < m; i++) { if (kol == m) {j++; i--; kol = 0; continue;} kol++; a[i][u] = g[j].S; ans += g[j].F.F; g[j].F.S--; if (g[j].F.S == 0) {kol = 0; j++;} } cout << ans << endl; for (int i = 0; i < 6; i++) cout << a[0][i] + 1 << " "; cout << endl; set <int> pr; pr.clear(); for (int i = 0; i < 6; i++) pr.insert(a[0][i]); kol = 0; for (int i = 1; i < m; i++) { set <int> gr; gr.clear(); for (int j = 0; j < 6; j++) gr.insert(a[i][j]); vector <int> swp; swp.clear(); while (sz(pr) > 0) { if (gr.find(*pr.begin()) == gr.end()) swp.pb(*pr.begin()); gr.erase(*pr.begin()); pr.erase(pr.begin()); } for (auto it : swp) { kol++; gr.erase(gr.begin()); } for (int j = 0; j < 6; j++) pr.insert(a[i][j]); } cout << kol << endl; pr.clear(); for (int i = 0; i < 6; i++) pr.insert(a[0][i]); for (int i = 1; i < m; i++) { set <int> gr; gr.clear(); for (int j = 0; j < 6; j++) gr.insert(a[i][j]); vector <int> swp; swp.clear(); while (sz(pr) > 0) { if (gr.find(*pr.begin()) == gr.end()) swp.pb(*pr.begin()); gr.erase(*pr.begin()); pr.erase(pr.begin()); } for (auto it : swp) { cout << i << " " << it + 1 << " " << *gr.begin() + 1 << endl; gr.erase(gr.begin()); } for (int j = 0; j < 6; j++) pr.insert(a[i][j]); } }

Compilation message (stderr)

hokej.cpp: In function 'int main()':
hokej.cpp:69:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for (int i = 0; i < 6; i++) cout << a[0][i] + 1 << " "; cout << endl;
     ^~~
hokej.cpp:69:61: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for (int i = 0; i < 6; i++) cout << a[0][i] + 1 << " "; cout << endl;
                                                             ^~~~
hokej.cpp:94:19: warning: unused variable 'it' [-Wunused-variable]
         for (auto it : swp)
                   ^~
#Verdict Execution timeMemoryGrader output
Fetching results...