답안 #591390

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
591390 2022-07-07T11:18:30 Z cheissmart 최후의 만찬 (IOI12_supper) C++14
26 / 100
376 ms 17384 KB
#include "advisor.h"
#include <bits/stdc++.h>
#include <bits/extc++.h>
#define IO_OP ios::sync_with_stdio(0), cin.tie(0)
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1e9 + 7;

void ComputeAdvice(int *a, int n, int k, int m) {
    vi next_occ(n, INF), nxt(n);
    for(int i = n - 1; i >= 0; i--) {
        nxt[i] = next_occ[a[i]];
        next_occ[a[i]] = i;
    }
    set<pi> s;
    ordered_set<int> tt;
    for(int i = 0; i < k; i++) {
        s.insert({next_occ[i], i});
        tt.insert(i);
    }
    for(int i = 0; i < n; i++) {
        if(tt.find(a[i]) != tt.end()) {
            s.erase({i, a[i]});
            s.insert({nxt[i], a[i]});
        } else {
            auto[pos, val] = *s.rbegin();
            s.erase({pos, val});
            int rk = tt.order_of_key(val);
            for(int j = 0; j < 15; j++)
                WriteAdvice(rk >> j & 1);
            tt.erase(val);

            s.insert({nxt[i], a[i]});
            tt.insert(a[i]);
        }
    }
}
// WriteAdvice
#include "assistant.h"
#include <bits/stdc++.h>
#include <bits/extc++.h>
#define IO_OP ios::sync_with_stdio(0), cin.tie(0)
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1e9 + 7;

void Assist(unsigned char *a, int n, int k, int r) {
    ordered_set<int> tt;
    for(int i = 0; i < k; i++) {
        tt.insert(i);
    }
    int sz = 0;
    for(int i = 0; i < n; i++) {
        int req = GetRequest();
        if(tt.find(req) != tt.end()) {
        } else {
            int rk = 0;
            for(int j = 0; j < 15; j++)
                rk += int(a[sz++]) << j;
            int val = *tt.find_by_order(rk);
            PutBack(val);
            tt.erase(val);
            tt.insert(req);
        }
    }
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:42:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   42 |             auto[pos, val] = *s.rbegin();
      |                 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 480 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 2 ms 768 KB Output is correct
4 Correct 7 ms 864 KB Output is correct
5 Incorrect 1 ms 668 KB Error - advice is too long
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 1588 KB Output is correct
2 Correct 111 ms 4572 KB Output is correct
3 Runtime error 367 ms 17384 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 237 ms 9248 KB Output is correct
2 Correct 288 ms 11592 KB Output is correct
3 Correct 281 ms 11528 KB Output is correct
4 Correct 266 ms 11544 KB Output is correct
5 Correct 229 ms 9356 KB Output is correct
6 Correct 283 ms 11756 KB Output is correct
7 Correct 276 ms 11236 KB Output is correct
8 Correct 376 ms 14008 KB Output is correct
9 Correct 215 ms 9516 KB Output is correct
10 Correct 279 ms 11756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 784 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 279 ms 11228 KB Output is partially correct - 772365 bits used
2 Correct 294 ms 11416 KB Output is partially correct - 742095 bits used
3 Correct 283 ms 11544 KB Output is partially correct - 712470 bits used
4 Correct 299 ms 11616 KB Output is partially correct - 712005 bits used
5 Correct 290 ms 11540 KB Output is partially correct - 710610 bits used
6 Correct 293 ms 11520 KB Output is partially correct - 712155 bits used
7 Correct 274 ms 11564 KB Output is partially correct - 711090 bits used
8 Correct 290 ms 11576 KB Output is partially correct - 713340 bits used
9 Correct 272 ms 11640 KB Output is partially correct - 712830 bits used
10 Correct 356 ms 14064 KB Output is partially correct - 1117620 bits used