제출 #1056455

#제출 시각아이디문제언어결과실행 시간메모리
1056455otariusOlympiads (BOI19_olympiads)C++17
100 / 100
45 ms12348 KiB
#include <bits/stdc++.h> #include <bits/extc++.h> using namespace __gnu_pbds; using namespace std; // #pragma GCC optimize("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define ff first #define sc second #define pb push_back #define ll long long #define pll pair<ll, ll> #define pii pair<int, int> #define ull unsigned long long #define all(x) (x).begin(),(x).end() #define int long long // #define int unsigned long long // #define ordered_set(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> // #define ordered_multiset(T) tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update> void open_file(string filename) { freopen((filename + ".in").c_str(), "r", stdin); freopen((filename + ".out").c_str(), "w", stdout); } // const ll mod = 1e9 + 7; // const ll mod = 998244353; const ll inf = 1e9; const ll biginf = 1e18; const int maxN = 505; const int maxV = 6 * 1e3 + 25; struct node { vector<int> B; int val; }; bool used[maxN]; deque<node> dq[maxV]; int n, k, c, arr[maxN][10]; node getmax() { int sum = 0; vector<int> vec; bool used_[n + 1] = {}; for (int i = 1; i <= k; i++) { int mx = -inf, pos; for (int j = 1; j <= n; j++) { if (used[j]) continue; if (mx < arr[j][i]) { mx = arr[j][i]; pos = j; } } sum += mx; if (used_[pos]) { for (int j = 1; j <= n; j++) { if (used[j] == 0 && used_[j] == 0) { pos = j; break; } } } if (used_[pos]) return {{}, 0}; vec.pb(pos); used_[pos] = 1; } return {vec, sum}; } void solve() { cin >> n >> k >> c; for (int i = 1; i <= n; i++) for (int j = 1; j <= k; j++) cin >> arr[i][j]; set<pair<int, pair<vector<int>, int>>> st; st.insert({getmax().val, {{}, 0}}); int A_A_A; while (c--) { pair<int, pair<vector<int>, int>> curr = *st.rbegin(); A_A_A = curr.ff; st.erase(--st.end()); int pos = curr.sc.sc; vector<int> v = curr.sc.ff; for (int x : v) used[x] = 1; vector<int> cur = getmax().B; for (int i = pos; i < k; i++) { used[cur[i]] = 1; vector<int> tmp = v; tmp.pb(cur[i]); st.insert({getmax().val, {tmp, i}}); used[cur[i]] = 0; } for (int x : v) used[x] = 0; } cout << A_A_A; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); cout << '\n'; } return 0; }

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

olympiads.cpp: In function 'void open_file(std::string)':
olympiads.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((filename + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
olympiads.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen((filename + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
olympiads.cpp: In function 'node getmax()':
olympiads.cpp:56:22: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   56 |         if (used_[pos]) {
      |             ~~~~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...