제출 #984319

#제출 시각아이디문제언어결과실행 시간메모리
984319kh0iOlympiads (BOI19_olympiads)C++17
0 / 100
31 ms756 KiB
#include "bits/stdc++.h" using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) #endif using ll = long long; using pii = pair<int, int>; #define F first #define S second #define sz(x) (int)((x).size()) #define all(x) (x).begin(), (x).end() mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll get_rand(ll l, ll r) { assert(l <= r); return uniform_int_distribution<ll> (l, r)(rng); } #define BB bitset<500> int n, k, c; struct Point{ int i, j, pt; friend bool operator < (const Point &x, const Point &y){ return x.pt > y.pt; } }; vector<Point> e; struct Partition{ BB banned; int fix = 0; ll weight = 0; vector<int> span; Partition(BB _banned, int _fix) : banned(_banned), fix(_fix) { vector<bool> used(k, 0); vector<bool> in_span(n, 0); for(int i = 0; i < sz(e); ++i){ if(!banned[e[i].i] and !used[e[i].j]){ weight += e[i].pt; used[e[i].j] = 1; if(!in_span[e[i].i]) span.push_back(e[i].i); in_span[e[i].i] = 1; } } for(int i = 0; i < sz(e); ++i){ if(sz(span) == k) break; if(banned[e[i].i] or in_span[e[i].i]) continue; span.push_back(e[i].i); in_span[e[i].i] = 1; } sort(all(span)); } bool friend operator < (const Partition &x, const Partition &y){ return x.weight < y.weight; } }; void solve(){ cin >> n >> k >> c; for(int i = 0; i < n; ++i){ for(int j = 0; j < k; ++j){ int x; cin >> x; e.push_back({i, j, x}); } } sort(all(e)); priority_queue<Partition> pq; pq.push(Partition(BB(), 0)); for(int i = 1; i <= c; ++i){ assert(!pq.empty()); Partition a = pq.top(); pq.pop(); debug(a.weight, a.span); for(int i : a.span) debug(e[i].i, e[i].j, e[i].pt); if(i == c){ cout << a.weight; return; } while(a.fix < sz(a.span)){ BB t = a.banned; t[a.span[a.fix]] = 1; auto A = Partition(t, a.fix); if(sz(A.span) == k) pq.push(A); ++a.fix; } } } int32_t main() { cin.tie(nullptr)->sync_with_stdio(0); #define task "troll" if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int test = 1; // cin >> test; for(int i = 1; i <= test; ++i){ // cout << "Case #" << i << ": "; solve(); } #ifdef LOCAL cerr << "\n[Time]: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n"; #endif return 0; }

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

olympiads.cpp: In function 'void solve()':
olympiads.cpp:87:17: warning: unused variable 'i' [-Wunused-variable]
   87 |         for(int i : a.span)
      |                 ^
olympiads.cpp: In function 'int32_t main()':
olympiads.cpp:110:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  110 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
olympiads.cpp:111:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  111 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...