답안 #812999

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
812999 2023-08-07T12:35:54 Z Andrey 최후의 만찬 (IOI12_supper) C++14
0 / 100
2500 ms 10464 KB
#include<bits/stdc++.h>
#include "advisor.h"
using namespace std;

vector<int> haha[100001];
void ComputeAdvice(int *c, int n, int k, int m) {
    int br = 0,z = 1;
    while(z <= n) {
        z*=2;
        br++;
    }
    vector<int> ans(0);
    vector<int> p(n);
    vector<bool> bruh(n);
    int a,b;
    priority_queue<pair<int,int>> idk;
    for(int i = 0; i < n; i++) {
        haha[c[i]].push_back(i);
    }
    for(int i = 0; i < n; i++) {
        haha[i].push_back(INT_MAX);
    }
    for(int i = 0; i < k; i++) {
        bruh[i] = true;
        idk.push({haha[i][0],i});
    }
    for(int i = 0; i < n; i++) {
        if(bruh[c[i]]) {
            p[c[i]]++;
            idk.push({haha[c[i]][p[c[i]]],c[i]});
            ans.push_back(INT_MAX);
        }
        else {
            a = idk.top().first;
            b = idk.top().second;
            bruh[b] = false;
            idk.pop();
            ans.push_back(b);
            p[c[i]]++;
            idk.push({haha[c[i]][p[c[i]]],c[i]});
            bruh[c[i]] = true;
        }
    }
    vector<int> sb(n);
    for(int i = 0; i < n; i++) {
        if(ans[i] != INT_MAX) {
            sb[ans[i]]++;
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < sb[i]; j++) {
            WriteAdvice(1);
        }
        WriteAdvice(0);
    }
}
#include<bits/stdc++.h>
#include "assistant.h"
using namespace std;

void Assist(unsigned char *a, int n, int k, int r) {
    int br = 0,z = 1,x = 0,b;
    vector<int> sb(n);
    for(int i = 0; i < r; i++) {
        if((int)a[i] == 0) {
            br++;
        }
        else {
            sb[br]++;
        }
    }
    vector<bool> bruh(n);
    for(int i = 0; i < k; i++) {
        bruh[i] = true;
    }
    for(int i = 0; i < n; i++) {
        b = GetRequest();
        if(!bruh[b]) {
            for(int j = 0; j < n; j++) {
                if(bruh[j] && sb[j] > 0) {
                    sb[j]--;
                    bruh[b] = true;
                    bruh[j] = false;
                    PutBack(j);
                    break;
                }
            }
        }
    }
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:15:9: warning: variable 'a' set but not used [-Wunused-but-set-variable]
   15 |     int a,b;
      |         ^

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:6:16: warning: unused variable 'z' [-Wunused-variable]
    6 |     int br = 0,z = 1,x = 0,b;
      |                ^
assistant.cpp:6:22: warning: unused variable 'x' [-Wunused-variable]
    6 |     int br = 0,z = 1,x = 0,b;
      |                      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2956 KB Output is correct
2 Incorrect 3 ms 2960 KB Error - Not putting back color when it is not on the scaffold
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 3736 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2596 ms 8968 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 3320 KB Error - Not putting back color when it is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2508 ms 10248 KB Time limit exceeded
2 Execution timed out 2513 ms 10308 KB Time limit exceeded
3 Execution timed out 2507 ms 10228 KB Time limit exceeded
4 Execution timed out 2536 ms 10276 KB Time limit exceeded
5 Execution timed out 2602 ms 10216 KB Time limit exceeded
6 Execution timed out 2583 ms 10380 KB Time limit exceeded
7 Execution timed out 2505 ms 10292 KB Time limit exceeded
8 Execution timed out 2591 ms 10396 KB Time limit exceeded
9 Execution timed out 2504 ms 10360 KB Time limit exceeded
10 Execution timed out 2578 ms 10464 KB Time limit exceeded