답안 #70129

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70129 2018-08-22T11:38:15 Z vanogam popa (BOI18_popa) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
int a,s,mas[10002],d[10002],f[10002],d1[10002],f1[10002],g,h,j,k,l,i,n,m;
#ifdef hax
int query(int a,int b,int c,int d){
    int g1=mas[a],g2=mas[c];
    for(;a<=b;a++){
        g1=__gcd(mas[a],g1);
    }

    for(;c<=d;c++){
        g2=__gcd(mas[c],g2);
    }
//cout<<g1<<"  "<<g2<<endl;
    return g1==g2;
}
#endif
int solve(int n,int* d,int *f){
    memset(d,~0,sizeof d);
    memset(f,~0,sizeof f);
    stack<int> q;
    q.push(0);
    int y;
    for(int i=1;i<n;i++){
        while(q.size()){//cout<<q.size();
            if(!query(q.top(),i,i,i)){
                //cout<<i<<" "<<q.top()<<endl;
                if(f[q.top()]!=-1)
                    d[i]=f[q.top()];
                    f[q.top()]=i;
                    break;
                }
                else{
                    y=q.top();
                    q.pop();
                }

        }
//cout<<i<<" "<<y<<" L"<<endl;
        if(!q.size()){d[i]=y;}
        q.push(i);
    }
    while(q.size()>1) q.pop();
    return q.top();

}
#ifdef hax
main(){
    cin>>n>>k;
    for(i=0;i<n;i++){
        cin>>mas[i];
    }
    l=solve(n,d,f);
    if(k!=l) {cout<<"!"<<l<<"!";return 0;}
    cout<<"RROT IS OK : "<<l<<endl;
    for(i=0;i<n;i++){
        cin>>d1[i];
    }

    for(i=0;i<n;i++){
        cin>>f1[i];
    }

    for(i=0;i<n;i++){
        cout<<d[i];
        if(d[i]!=d1[i]) cout<<"!";
        cout<<" ";
    }
    cout<<endl;
    for(i=0;i<n;i++){
        cout<<f[i];
        if(f[i]!=f1[i]) cout<<"!";
        cout<<" ";
    }
    cout<<endl;

}
#endif
/*
6 3
12 4 16 2 2 20
-1 0 -1 1 -1 -1
-1 2 -1 4 5 -1
*/

Compilation message

popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:19:24: warning: argument to 'sizeof' in 'void* memset(void*, int, size_t)' call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
     memset(d,~0,sizeof d);
                        ^
popa.cpp:20:24: warning: argument to 'sizeof' in 'void* memset(void*, int, size_t)' call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
     memset(f,~0,sizeof f);
                        ^
popa.cpp:26:17: error: 'query' was not declared in this scope
             if(!query(q.top(),i,i,i)){
                 ^~~~~
popa.cpp:28:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
                 if(f[q.top()]!=-1)
                 ^~
popa.cpp:30:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
                     f[q.top()]=i;
                     ^