제출 #70131

#제출 시각아이디문제언어결과실행 시간메모리
70131vanogampopa (BOI18_popa)C++14
0 / 100
10 ms392 KiB
#include<bits/stdc++.h> #include<popa.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 */

컴파일 시 표준 에러 (stderr) 메시지

popa.cpp: In function 'int solve(int, int*, int*)':
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(d,~0,sizeof d);
                        ^
popa.cpp:21: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:29:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
                 if(f[q.top()]!=-1)
                 ^~
popa.cpp:31:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
                     f[q.top()]=i;
                     ^
popa.cpp:41:27: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
         if(!q.size()){d[i]=y;}
                       ~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...