답안 #272101

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
272101 2020-08-18T09:01:07 Z 79brue 최후의 만찬 (IOI12_supper) C++14
17 / 100
727 ms 28632 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "advisor.h"

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> idx_set;

namespace{
    int n, k, m, b;
    int arr[100002];
    int ans[100002];

    bool chk[100002];
    priority_queue<pair<int, int> > pq;
    vector<int> times[100002];

    idx_set st;
}

void ComputeAdvice(int *ARR, int N, int K, int M){
    n = N, k = K, m = M;
    b=15;
    for(int i=0; i<n; i++){
        arr[i] = ARR[i];
        times[arr[i]].push_back(i);
    }
    for(int i=0; i<n; i++) times[i].push_back(1e9);
    for(int i=0; i<n; i++){
        reverse(times[i].begin(), times[i].end());
        if(i<k) pq.push({times[i].back(), i}), st.insert(i);
    }

    for(int i=0; i<k; i++) chk[i] = 1;
    for(int i=0; i<n; i++){
        times[arr[i]].pop_back();
        if(chk[arr[i]]){
            ans[i] = k;
            pq.push({times[arr[i]].back(), arr[i]});
            continue;
        }

        pair<int, int> tmp = pq.top(); pq.pop();
        ans[i] = st.order_of_key(tmp.second);
//        printf("erased: %d\n", tmp.second);
        st.erase(st.find(tmp.second));
        st.insert(arr[i]);
        chk[tmp.second] = 0;
        pq.push({times[arr[i]].back(), arr[i]});
        chk[arr[i]] = 1;
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<b; j++){
            WriteAdvice(!!(ans[i] & (1<<j)));
        }
    }
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "assistant.h"

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> idx_set;

namespace{
    int n, k, l, b;
    int arr[2000002];
    idx_set st;
}

void Assist(unsigned char *ARR, int N, int K, int R) {
    n = N, k = K, l = R;
    b=15;
    for(int i=0; i<R; i++) arr[i] = ARR[i];

    for(int i=0; i<k; i++){
        st.insert(i);
    }

    for(int i=0; i<n; i++){
        int tpt = GetRequest();
        int tmp = 0;
        for(int j=0; j<b; j++){
            tmp += (1<<j) * arr[i*b+j];
        }

        if(tmp != k){
            int tx = *st.find_by_order(tmp);
//            printf("erased: %d\n", tx);
            PutBack(tx);
            st.erase(st.find(tx));
            st.insert(tpt);
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5376 KB Output is correct
2 Correct 3 ms 5376 KB Output is correct
3 Correct 8 ms 5632 KB Output is correct
4 Correct 17 ms 5888 KB Output is correct
5 Incorrect 6 ms 5888 KB Error - advice is too long
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 7664 KB Output is correct
2 Correct 264 ms 16336 KB Output is correct
3 Incorrect 571 ms 28632 KB Error - Putting back a color when it is already on the scaffold
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 440 ms 23496 KB Output is correct
2 Correct 574 ms 27976 KB Output is correct
3 Correct 560 ms 28120 KB Output is correct
4 Correct 553 ms 28096 KB Output is correct
5 Correct 509 ms 27864 KB Output is correct
6 Correct 569 ms 27864 KB Output is correct
7 Correct 585 ms 27864 KB Output is correct
8 Correct 622 ms 27360 KB Output is correct
9 Correct 528 ms 28632 KB Output is correct
10 Correct 568 ms 28168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 5888 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 582 ms 27352 KB Output is partially correct - 1500000 bits used
2 Correct 567 ms 27568 KB Output is partially correct - 1500000 bits used
3 Correct 604 ms 27944 KB Output is partially correct - 1500000 bits used
4 Correct 562 ms 27864 KB Output is partially correct - 1500000 bits used
5 Correct 583 ms 28080 KB Output is partially correct - 1500000 bits used
6 Correct 579 ms 28128 KB Output is partially correct - 1500000 bits used
7 Correct 564 ms 27864 KB Output is partially correct - 1497585 bits used
8 Correct 649 ms 27864 KB Output is partially correct - 1500000 bits used
9 Correct 727 ms 27864 KB Output is partially correct - 1500000 bits used
10 Correct 615 ms 27368 KB Output is partially correct - 1500000 bits used