# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
271944 |
2020-08-18T08:04:00 Z |
임성재(#5104) |
최후의 만찬 (IOI12_supper) |
C++14 |
|
2500 ms |
150800 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));
update(i, 1);
}
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;
| ~~~~~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2532 ms |
135424 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2531 ms |
136952 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2536 ms |
147680 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
55 ms |
135664 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2575 ms |
149880 KB |
Time limit exceeded |
2 |
Execution timed out |
2558 ms |
149984 KB |
Time limit exceeded |
3 |
Execution timed out |
2585 ms |
150504 KB |
Time limit exceeded |
4 |
Execution timed out |
2598 ms |
150496 KB |
Time limit exceeded |
5 |
Execution timed out |
2581 ms |
150520 KB |
Time limit exceeded |
6 |
Execution timed out |
2564 ms |
150456 KB |
Time limit exceeded |
7 |
Execution timed out |
2511 ms |
150240 KB |
Time limit exceeded |
8 |
Execution timed out |
2541 ms |
150496 KB |
Time limit exceeded |
9 |
Execution timed out |
2586 ms |
150512 KB |
Time limit exceeded |
10 |
Execution timed out |
2567 ms |
150800 KB |
Time limit exceeded |