Submission #812762

# Submission time Handle Problem Language Result Execution time Memory
812762 2023-08-07T10:55:33 Z Andrey Last supper (IOI12_supper) C++14
Compilation error
0 ms 0 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;
        p[i]++;
        idk.push({haha[i][0],i});
    }
    for(int i = 0; i < n; i++) {
        if(bruh[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;
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = br-1; j >= 0; j--) {
            if((1 << j)&ans[i]) {
                WriteAdvice(1);
            }
            else {
                WriteAdvice(0);
            }
        }
    }
}

#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;
        p[i]++;
        idk.push({haha[i][0],i});
    }
    for(int i = 0; i < n; i++) {
        if(bruh[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;
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = br-1; j >= 0; j--) {
            if((1 << j)&ans[i]) {
                WriteAdvice(1);
            }
            else {
                WriteAdvice(0);
            }
        }
    }
}

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 ComputeAdvice(int*, int, int, int)':
assistant.cpp:15:9: warning: variable 'a' set but not used [-Wunused-but-set-variable]
   15 |     int a,b;
      |         ^
/usr/bin/ld: /tmp/ccyZaV4C.o: in function `ComputeAdvice(int*, int, int, int)':
assistant.cpp:(.text+0x5d6): undefined reference to `WriteAdvice(unsigned char)'
/usr/bin/ld: assistant.cpp:(.text+0x5f3): undefined reference to `WriteAdvice(unsigned char)'
/usr/bin/ld: /tmp/cctUHPRD.o: in function `main':
assistant_grader.cpp:(.text.startup+0x21e): undefined reference to `Assist(unsigned char*, int, int, int)'
collect2: error: ld returned 1 exit status