Submission #586766

# Submission time Handle Problem Language Result Execution time Memory
586766 2022-06-30T16:50:11 Z keta_tsimakuridze Last supper (IOI12_supper) C++14
Compilation error
0 ms 0 KB
#include "advisor.h"
#include<bits/stdc++.h>
#define pii pair<int,int>
#define f first
#define s second

using namespace std;
const int Nn = 1e5 + 5;
set<int> s[Nn];
void ComputeAdvice(int *c, int N, int K, int M) {
    for(int i = 0; i < N; i++) s[c[i]].insert(i + K), s[i].insert(N + K + 1);
    for(int i = 0; i < K; i++) s[i].insert(i);
    set<int> on;
    vector<int> f(N + K);
    set<pair<int,int> > cur;
    for(int i = 0; i < K; i++) {
        cur.insert({*s[i].upper_bound(i), i});
        on.insert(i);
    }
    int ans = 0;
    for(int i = K; i < N + K; i++) {
        int x = c[i - K];
        if(on.count(x)) {
            cur.erase({i, *--s[x].upper_bound(i - 1)});
            cur.insert({*s[x].upper_bound(i), i});
            continue;
        }
        ++ans;
        pii p = *--cur.end();
        cur.erase(p);
        f[p.s] = 1;
        if(p.s < K) {
            on.erase(p.s);
        } else on.erase(c[p.s - K]);

        cur.insert({*s[x].upper_bound(i), i});
    }
     //   cout << "advisoris " << ans << endl;
    for(int i = 0; i < N + K; i++) WriteAdvice(f[i]), cout << f[i]; cout << "++" << endl;
}
#include "advisor.h"
#include<bits/stdc++.h>
#define pii pair<int,int>
#define f first
#define s second

using namespace std;
const int Nn = 1e5 + 5;
set<int> s[Nn];
void ComputeAdvice(int *c, int N, int K, int M) {
    for(int i = 0; i < N; i++) s[c[i]].insert(i + K), s[i].insert(N + K + 1);
    for(int i = 0; i < K; i++) s[i].insert(i);
    set<int> on;
    vector<int> f(N + K);
    set<pair<int,int> > cur;
    for(int i = 0; i < K; i++) {
        cur.insert({*s[i].upper_bound(i), i});
        on.insert(i);
    }
    int ans = 0;
    for(int i = K; i < N + K; i++) {
        int x = c[i - K];
        if(on.count(x)) {
            cur.erase({i, *--s[x].upper_bound(i - 1)});
            cur.insert({*s[x].upper_bound(i), i});
            continue;
        }
        ++ans;
        pii p = *--cur.end();
        cur.erase(p);
        f[p.s] = 1;
        if(p.s < K) {
            on.erase(p.s);
        } else on.erase(c[p.s - K]);

        cur.insert({*s[x].upper_bound(i), i});
    }
     //   cout << "advisoris " << ans << endl;
    for(int i = 0; i < N + K; i++) WriteAdvice(f[i]), cout << f[i]; cout << "++" << endl;
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:40:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   40 |     for(int i = 0; i < N + K; i++) WriteAdvice(f[i]), cout << f[i]; cout << "++" << endl;
      |     ^~~
advisor.cpp:40:69: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   40 |     for(int i = 0; i < N + K; i++) WriteAdvice(f[i]), cout << f[i]; cout << "++" << endl;
      |                                                                     ^~~~

assistant.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
assistant.cpp:40:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   40 |     for(int i = 0; i < N + K; i++) WriteAdvice(f[i]), cout << f[i]; cout << "++" << endl;
      |     ^~~
assistant.cpp:40:69: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   40 |     for(int i = 0; i < N + K; i++) WriteAdvice(f[i]), cout << f[i]; cout << "++" << endl;
      |                                                                     ^~~~
/usr/bin/ld: /tmp/ccnFCzXZ.o: in function `ComputeAdvice(int*, int, int, int)':
assistant.cpp:(.text+0xa0c): undefined reference to `WriteAdvice(unsigned char)'
/usr/bin/ld: /tmp/ccpF9rzZ.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