# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
124895 |
2019-07-04T06:01:28 Z |
윤교준(#3050) |
Olympiads (BOI19_olympiads) |
C++14 |
|
2000 ms |
96068 KB |
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define befv(V) ((V)[sz(V)-2])
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define revv(V) reverse(allv(V))
#define upmax(a,b) (a)=max((a),(b))
#define INF (0x3f3f3f3f)
using namespace std;
typedef long long ll;
struct NOD {
ll key;
int cost;
void f(vector<int> V) {
key = 0;
for(int t = 6-sz(V); t--;) V.eb(511);
sorv(V);
for(int i = 0; i < 6; i++)
key |= ll(V[i]) << (9*i);
}
void g(vector<int> &V) {
for(int i = 0; i < 6; i++) {
int c = (key >> (9*i)) & 511;
if(c < 501) V.eb(c);
else break;
}
}
bool operator < (const NOD &t) const {
return cost < t.cost;
}
};
unordered_set<ll> CMP;
priority_queue<NOD> PQ;
int A[500][6];
int N, K, C;
void cal(NOD &nod) {
nod.cost = 0;
vector<int> V; nod.g(V);
for(int i = 0; i < K; i++) {
int mx = 0;
for(int v : V)
if(mx < A[v][i]) mx = A[v][i];
nod.cost += mx;
}
}
int main() {
ios::sync_with_stdio(false);
cin >> N >> K >> C;
for(int i = 0; i < N; i++) for(int j = 0; j < K; j++) cin >> A[i][j];
{
bitset<500> chk;
vector<int> V;
for(int j = 0; j < K; j++) {
int mx = -1, mxi = -1;
for(int i = 0; i < N; i++) {
if(A[i][j] <= mx) continue;
mx = A[i][j];
mxi = i;
}
if(!chk[mxi]) {
V.eb(mxi);
chk[mxi] = true;
}
}
for(int t = K-sz(V); t--;) {
for(int i = 0; i < N; i++)
if(!chk[i]) {
chk[i] = true;
V.eb(i);
break;
}
}
NOD nod; nod.f(V);
cal(nod);
PQ.push(nod);
CMP.insert(nod.key);
}
bitset<500> chk;
for(NOD nod; !PQ.empty();) {
nod = PQ.top(); PQ.pop(); C--;
if(!C) {
cout << nod.cost << endl;
break;
}
chk.reset();
vector<int> V; nod.g(V);
for(int v : V) chk[v] = true;
for(int i = 0; i < N; i++) if(!chk[i]) {
NOD nxt;
for(int j = 0; j < K; j++) {
int bf = V[j];
V[j] = i;
nxt.f(V);
cal(nxt);
V[j] = bf;
auto it = CMP.find(nxt.key);
if(CMP.end() == it) {
CMP.insert(nxt.key);
PQ.push(nxt);
}
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
716 ms |
8124 KB |
Output is correct |
2 |
Correct |
729 ms |
8092 KB |
Output is correct |
3 |
Correct |
737 ms |
8084 KB |
Output is correct |
4 |
Correct |
676 ms |
8132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
216 ms |
5528 KB |
Output is correct |
2 |
Correct |
207 ms |
5372 KB |
Output is correct |
3 |
Correct |
216 ms |
5372 KB |
Output is correct |
4 |
Correct |
204 ms |
5336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2068 ms |
96068 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
716 ms |
8124 KB |
Output is correct |
2 |
Correct |
729 ms |
8092 KB |
Output is correct |
3 |
Correct |
737 ms |
8084 KB |
Output is correct |
4 |
Correct |
676 ms |
8132 KB |
Output is correct |
5 |
Correct |
216 ms |
5528 KB |
Output is correct |
6 |
Correct |
207 ms |
5372 KB |
Output is correct |
7 |
Correct |
216 ms |
5372 KB |
Output is correct |
8 |
Correct |
204 ms |
5336 KB |
Output is correct |
9 |
Execution timed out |
2068 ms |
96068 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |