Submission #797022

#TimeUsernameProblemLanguageResultExecution timeMemory
797022ShithilaAliens (IOI16_aliens)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; const int mod = 1e9; int main() { int q; cin>>q; vector<int> num; vector<int> temp; map<int,int> chek; vector<int> prefix(q); int y=0; int bloksize=sqrt(q); for(int ll=0;ll<q;ll++) { char com; cin>>com; if(com=='+') { int n; cin>>n; if(chek.find((y+n)%mod)==chek.end()) { temp.push_back((y+n)%mod); chek[(y+n)%mod]=true; } } y=0; if(com=='?') { int l; int r; cin>>l>>r; for(int i=0;i<temp.size();i++) { if(temp[i]<=r && temp[i]>=l) { y=y+temp[i]; } } int left=0; int right=num.size()-1; int leftans=-1; int rightans=-1; while(left<=right) { int mid=left+right; mid=mid/2; if(num[mid]<=r) { rightans=mid; left=mid+1; } else { right=mid-1; } } left=0; right=num.size()-1; while(left<=right) { int mid=left+right; mid=mid/2; if(num[mid]>=l) { leftans=mid; right=mid-1; } else { left=mid+1; } } if(rightans==-1) y=y; else if(leftans==0) y=y+prefix[rightans]; else y=y+prefix[rightans]-prefix[leftans-1]; cout<<y<<endl; } if(temp.size()>=bloksize) { while(temp.empty()!=true) { num.push_back(temp.back()); temp.pop_back(); } sort(num.begin(),num.end()); for(int i=0;i<num.size();i++) { if(i!=0 ) prefix[i]=prefix[i-1]+num[i]; else prefix[i]=num[i]; } } } }

Compilation message (stderr)

aliens.cpp: In function 'int main()':
aliens.cpp:35:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |    for(int i=0;i<temp.size();i++)
      |                ~^~~~~~~~~~~~
aliens.cpp:82:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   82 |   if(temp.size()>=bloksize)
      |      ~~~~~~~~~~~^~~~~~~~~~
aliens.cpp:90:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |    for(int i=0;i<num.size();i++)
      |                ~^~~~~~~~~~~
/usr/bin/ld: /tmp/ccy6j21w.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccgmebRw.o:aliens.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccy6j21w.o: in function `main':
grader.cpp:(.text.startup+0xf0): undefined reference to `take_photos(int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status