Submission #18488

# Submission time Handle Problem Language Result Execution time Memory
18488 2016-02-06T07:04:20 Z eaststar 올림픽 피자 (tutorial5) C++14
Compilation error
0 ms 0 KB
#include "pizza.h"
void Init(){}
int cnt[8],q[1<<8][100010],s[1<<8],e[1<<8],s,m;
void Order(int n, int *a){
    int i,t=0;
    for(i=0;i<n;++i)if(!cnt[a[i]])break;
    if(i<n){
        for(i=0;i<n;++i)t+=(1<<a[i]);
        q[t][e[t]++]=m++;
    }
    else{
        Bake(m++);
        for(i=0;i<n;++i){
            --cnt[a[i]];
            if(!cnt[a[i]])s-=(1<<a[i]);
        }
    }
}
void Delivery(int x){
    int i,k,l=1e6;
    ++cnt[x];
    if(cnt[x]<2){
        s+=(1<<x);
        for(i=1;i<(1<<8);++i)if(i&(1<<x)){
            if(s&i!=i)continue;
            if(s[i]<e[i]&&l>q[i][s[i]])k=i,l=q[i][s[i]];
        }
        if(l<1e6){
            for(i=0;i<8;++i)if(k&(1<<i)){
                --cnt[i];
                if(!cnt[i])s-=(1<<i);
            }
            Bake(q[k][s[k]++]);
        }
    }
}

Compilation message

grader.cpp: In function ‘int main(int, char**)’:
grader.cpp:65:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
tutorial5.cpp:3:44: error: conflicting declaration ‘int s’
 int cnt[8],q[1<<8][100010],s[1<<8],e[1<<8],s,m;
                                            ^
tutorial5.cpp:3:28: note: previous declaration as ‘int s [256]’
 int cnt[8],q[1<<8][100010],s[1<<8],e[1<<8],s,m;
                            ^
tutorial5.cpp: In function ‘void Order(int, int*)’:
tutorial5.cpp:15:28: error: incompatible types in assignment of ‘int’ to ‘int [256]’
             if(!cnt[a[i]])s-=(1<<a[i]);
                            ^
tutorial5.cpp: In function ‘void Delivery(int)’:
tutorial5.cpp:23:10: error: incompatible types in assignment of ‘int’ to ‘int [256]’
         s+=(1<<x);
          ^
tutorial5.cpp:25:21: error: invalid operands of types ‘int [256]’ and ‘bool’ to binary ‘operator&’
             if(s&i!=i)continue;
                     ^
tutorial5.cpp:25:17: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
             if(s&i!=i)continue;
                 ^
tutorial5.cpp:31:29: error: incompatible types in assignment of ‘int’ to ‘int [256]’
                 if(!cnt[i])s-=(1<<i);
                             ^