# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
271929 |
2020-08-18T08:01:16 Z |
임성재(#5104) |
Last supper (IOI12_supper) |
C++14 |
|
2500 ms |
150680 KB |
#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define em emplace
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;
static queue<int> q[100010];
static set<pii> s;
static vector<int> ans;
static int mx;
static int tree[100010];
static void update(int i, int x) {
i++;
while(i <= 100000) {
tree[i] += x;
i += i & -i;
}
}
static int sum(int i) {
i++;
int ret = 0;
while(i) {
ret += tree[i];
i -= i & -i;
}
return ret;
}
void ComputeAdvice(int *C, int N, int K, int M) {
while(K >> mx) mx++;
for(int i=0; i<N; i++) {
q[C[i]].em(i);
}
for(int i=0; i<N; i++)
q[i].em(N);
for(int i=0; i<K; i++) {
s.insert(mp(q[i].front(), i));
}
for(int i=0; i<N; i++) {
if(s.begin()->fi == i) {
int x = s.begin()->se;
q[x].pop();
s.erase(s.begin());
s.insert(mp(q[x].front(), x));
ans.eb(0);
}
else {
int x = prev(s.end())->se;
s.erase(prev(s.end()));
q[C[i]].pop();
s.insert(mp(q[C[i]].front(), C[i]));
update(x, -1);
update(C[i], 1);
ans.eb(sum(x));
}
}
for(auto i : ans) {
for(int j=0; j<mx; j++) {
if(i & (1<<j)) WriteAdvice(1);
else WriteAdvice(0);
}
}
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define em emplace
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;
static int mx, n;
static int tree[100010];
static void update(int i, int x) {
i++;
while(i <= 100000) {
tree[i] += x;
i += i & -i;
}
}
static int sum(int i) {
i++;
int ret = 0;
while(i) {
ret += tree[i];
i -= i & -i;
}
return ret;
}
static int Find(int x) {
int l = 0, r = 100000 - 1;
while(l != r) {
int m = l + r + 1 >> 1;
if(sum(m) >= x) r = m;
else l = m+1;
}
return l;
}
void Assist(unsigned char *A, int N, int K, int R) {
while(K >> mx) mx++;
n = N;
for(int i=0; i<K; i++)
update(i, 1);
for(int i=0; i<N; i++) {
int b = 0;
for(int j=0; j<mx; j++) {
if(A[i*mx + j]) b |= (1<<j);
}
int x = GetRequest();
if(b) {
int y = Find(b);
update(x, 1);
update(y, -1);
PutBack(y);
}
}
}
Compilation message
assistant.cpp: In function 'int Find(int)':
assistant.cpp:46:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
46 | int m = l + r + 1 >> 1;
| ~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2521 ms |
135408 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2522 ms |
136632 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2531 ms |
147424 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
55 ms |
135664 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2544 ms |
149880 KB |
Time limit exceeded |
2 |
Execution timed out |
2554 ms |
150240 KB |
Time limit exceeded |
3 |
Execution timed out |
2570 ms |
150496 KB |
Time limit exceeded |
4 |
Execution timed out |
2566 ms |
150640 KB |
Time limit exceeded |
5 |
Execution timed out |
2590 ms |
150496 KB |
Time limit exceeded |
6 |
Execution timed out |
2573 ms |
150360 KB |
Time limit exceeded |
7 |
Execution timed out |
2550 ms |
150248 KB |
Time limit exceeded |
8 |
Execution timed out |
2524 ms |
150680 KB |
Time limit exceeded |
9 |
Execution timed out |
2574 ms |
150496 KB |
Time limit exceeded |
10 |
Execution timed out |
2509 ms |
150480 KB |
Time limit exceeded |