Submission #978424

#TimeUsernameProblemLanguageResultExecution timeMemory
978424alexddpopa (BOI18_popa)C++17
Compilation error
0 ms0 KiB
#include "popa.h" #include<bits/stdc++.h> using namespace std; int _s[1005],_n; int query(int a, int b, int c, int d) { int gc1=_s[a],gc2=_s[c]; for(int i=a;i<=b;i++) gc1 = __gcd(gc1,_s[i]); for(int i=c;i<=d;i++) gc2 = __gcd(gc2,_s[i]); if(gc1==gc2) return 1; return 0; } int myquery(int a, int b, int c, int d) { return query(min(a,b),max(a,b),min(c,d),max(c,d)); } vector<int> ord; void precalc(int limle[1005]) { for(int i=0;i<ord.size();i++) { int st=0,dr=i,ans=i; while(st<=dr) { int mij=(st+dr)/2; if(myquery(ord[mij],ord[i],ord[i],ord[i])) { ans=mij; dr=mij-1; } else st=mij+1; } limle[ord[i]] = ord[ans]; } } int tole[1005],tori[1005]; int limle[1005],limri[1005]; int calc(int le, int ri) { if(le>ri) return -1; if(le==ri) { tole[le]=tori[le]=-1; return le; } for(int root=le;root<=ri;root++) { if(limle[root]<=le && limri[root]>=ri) { tole[root] = calc(le,root-1); tori[root] = calc(root+1,ri); return root; } } return -5; } int solve(int N, int* Left, int* Right) { ord.clear(); for(int i=0;i<N;i++) ord.push_back(i); precalc(limle); reverse(ord.begin(),ord.end()); precalc(limri); //for(int i=0;i<N;i++) cout<<i<<" "<<limle[i]<<" "<<limri[i]<<" lim\n"; for(int i=0;i<N;i++) tole[i]=tori[i]=-1; int root = calc(0,N-1); for(int i=0;i<N;i++) { Left[i]=tole[i]; Right[i]=tori[i]; } return root; } /** 6 12 4 16 2 2 20 */ int _left[1005],_right[1005]; signed main() { cin>>_n; for(int i=0;i<_n;i++) cin>>_s[i]; int root = solve(_n,_left,_right); cout<<root<<" the root\n"; for(int i=0;i<_n;i++) { cout<<i<<" "<<_left[i]<<" "<<_right[i]<<" left and right\n"; } return 0; }

Compilation message (stderr)

popa.cpp: In function 'void precalc(int*)':
popa.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i=0;i<ord.size();i++)
      |                 ~^~~~~~~~~~~
/usr/bin/ld: /tmp/ccTN266m.o: in function `query(int, int, int, int)':
popa.cpp:(.text+0x0): multiple definition of `query(int, int, int, int)'; /tmp/ccGlXtZm.o:grader.cpp:(.text+0x50): first defined here
/usr/bin/ld: /tmp/ccTN266m.o: in function `main':
popa.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccGlXtZm.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status