제출 #1055499

#제출 시각아이디문제언어결과실행 시간메모리
1055499c2zi6카니발 티켓 (IOI20_tickets)C++14
25 / 100
485 ms122824 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "tickets.h" namespace TEST1 { ll find_maximum(int k, VVI table) { int n = table.size(); int m = table[0].size(); VI a; rep(i, n) a.pb(table[i][0]); sort(all(a)); ll ans = 0; rep(i, n/2) ans -= a[i]; rep(i, n/2) ans += a[i + n/2]; VVI answ(n, VI(m, 0)); allocate_tickets(answ); return ans; } }; namespace TEST4 { struct CELL { int x, y, val; }; bool operator<(const CELL& a, const CELL& b) { return a.val < b.val; } ll find_maximum(int k, VVI table) { int n = table.size(); int m = table[0].size(); vector<CELL> vec; rep(i, n) rep(j, m) { vec.pb({i, j, table[i][j]}); } sort(all(vec)); VVI a(n, VI(m, 1)); rep(i, n*m/2) { auto[x, y, val] = vec[i]; a[x][y] = 0; } ll ans = 0; VVI zro, mek; zro = mek = VVI(n); rep(i, n) { rep(j, m) { if (a[i][j]) { mek[i].pb(j); ans += table[i][j]; } else { zro[i].pb(j); ans -= table[i][j]; } } } VVI answ(n, VI(m, -1)); rep(r, m) { VI round(n, -1); int cnt = 0; /* cnt(1) - cnt(0) */ rep(i, n) { if (zro[i].size() == 0) { round[i] = mek[i].back(); mek[i].pop_back(); cnt++; } else if (mek[i].size() == 0) { round[i] = zro[i].back(); zro[i].pop_back(); cnt--; } } rep(i, n) if (round[i] == -1) { if (cnt > 0) { round[i] = zro[i].back(); zro[i].pop_back(); cnt--; } else { round[i] = mek[i].back(); mek[i].pop_back(); cnt++; } } rep(i, n) { int j = round[i]; answ[i][j] = r; } } allocate_tickets(answ); return ans; } }; ll find_maximum(int k, VVI table) { int n = table.size(); int m = table[0].size(); if (m == 1) return TEST1::find_maximum(k, table); if (m == k) return TEST4::find_maximum(k, table); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

tickets.cpp: In function 'll TEST4::find_maximum(int, VVI)':
tickets.cpp:66:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   66 |             auto[x, y, val] = vec[i];
      |                 ^
tickets.cpp: In function 'll find_maximum(int, VVI)':
tickets.cpp:121:6: warning: unused variable 'n' [-Wunused-variable]
  121 |  int n = table.size();
      |      ^
#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...