Submission #774750

#TimeUsernameProblemLanguageResultExecution timeMemory
774750boyliguanhanTeams (IOI15_teams)C++17
Compilation error
0 ms0 KiB
const uint Block=3000,Lim=500000; std::pair<uint,uint>P[Lim+5]; uint C[Lim/Block+5][Lim+5],F[Lim/Block+5]; uint W[1005][1005],n,c; bol solve(std::vector<uint>S) { std::vector<uint>A,B; std::sort(S.begin(),S.end());uint v=0; for(auto s:S) { if((v+=s)>n)return false; if(A.size()&&A.back()==s)B.back()+=A.back();else A.push_back(s),B.push_back(s); } for(uint i=0,p,r;i<A.size();i++) { p=0;while(p+1<c&&F[p+1]<=A[i])p++; r=std::min((p+1)*Block,n); for(uint j=A.size()-1,k=p*Block,c=0;j>=i&&~j;j--) { while(k<r&&P[k].second>=A[j])c+=P[k++].first<=A[i]; W[i][j]=c+C[p][A[j]]; } } for(uint i=0;i<A.size();i++)for(uint j=0;i+j<A.size();j++) { if(j)W[j][i+j]-=W[j-1][i+j]; if(i+j+1<A.size())W[j][i+j]-=W[j][i+j+1]; if(j&&i+j+1<A.size())W[j][i+j]+=W[j-1][i+j+1]; } for(uint i=0;i<A.size();i++) { for(uint j=i;j<A.size();j++)if(B[i]>=W[i][j])B[i]-=W[i][j],W[i][j]=0;else W[i][j]-=B[i],B[i]=0; if(B[i])return false; for(uint j=i+1;j<A.size();j++)W[i+1][j]+=W[i][j]; } return true; } int main() { uint q;scanf("%u",&n);for(uint i=0;i<n;i++)scanf("%u%u",&P[i].first,&P[i].second); std::sort(P,P+n); for(uint j=0,r;j<n;j+=Block) { F[j/Block]=P[j].first; std::sort(P+j,P+(r=std::min(j+Block,n)), [&](std::pair<uint,uint>a,std::pair<uint,uint>b){return a.second>b.second;}),c++; for(uint k=0;k<r;k++)C[c][P[k].second]++; for(uint k=n;k;k--)C[c][k-1]+=C[c][k]; } scanf("%u",&q); while(q--) { uint m;scanf("%u",&m); std::vector<uint>S(m); for(auto&v:S)scanf("%u",&v); puts(solve(S)?"1":"0"); } }

Compilation message (stderr)

teams.cpp:1:7: error: 'uint' does not name a type; did you mean 'int'?
    1 | const uint Block=3000,Lim=500000;
      |       ^~~~
      |       int
teams.cpp:2:6: error: 'pair' in namespace 'std' does not name a template type
    2 | std::pair<uint,uint>P[Lim+5];
      |      ^~~~
teams.cpp:1:1: note: 'std::pair' is defined in header '<utility>'; did you forget to '#include <utility>'?
  +++ |+#include <utility>
    1 | const uint Block=3000,Lim=500000;
teams.cpp:3:1: error: 'uint' does not name a type; did you mean 'int'?
    3 | uint C[Lim/Block+5][Lim+5],F[Lim/Block+5];
      | ^~~~
      | int
teams.cpp:4:1: error: 'uint' does not name a type; did you mean 'int'?
    4 | uint W[1005][1005],n,c;
      | ^~~~
      | int
teams.cpp:5:1: error: 'bol' does not name a type; did you mean 'bool'?
    5 | bol solve(std::vector<uint>S)
      | ^~~
      | bool
teams.cpp: In function 'int main()':
teams.cpp:40:5: error: 'uint' was not declared in this scope; did you mean 'int'?
   40 |     uint q;scanf("%u",&n);for(uint i=0;i<n;i++)scanf("%u%u",&P[i].first,&P[i].second);
      |     ^~~~
      |     int
teams.cpp:40:24: error: 'n' was not declared in this scope
   40 |     uint q;scanf("%u",&n);for(uint i=0;i<n;i++)scanf("%u%u",&P[i].first,&P[i].second);
      |                        ^
teams.cpp:40:12: error: 'scanf' was not declared in this scope
   40 |     uint q;scanf("%u",&n);for(uint i=0;i<n;i++)scanf("%u%u",&P[i].first,&P[i].second);
      |            ^~~~~
teams.cpp:40:35: error: expected ';' before 'i'
   40 |     uint q;scanf("%u",&n);for(uint i=0;i<n;i++)scanf("%u%u",&P[i].first,&P[i].second);
      |                                   ^~
      |                                   ;
teams.cpp:40:40: error: 'i' was not declared in this scope
   40 |     uint q;scanf("%u",&n);for(uint i=0;i<n;i++)scanf("%u%u",&P[i].first,&P[i].second);
      |                                        ^
teams.cpp:40:62: error: 'P' was not declared in this scope
   40 |     uint q;scanf("%u",&n);for(uint i=0;i<n;i++)scanf("%u%u",&P[i].first,&P[i].second);
      |                                                              ^
teams.cpp:41:10: error: 'sort' is not a member of 'std'
   41 |     std::sort(P,P+n);
      |          ^~~~
teams.cpp:41:15: error: 'P' was not declared in this scope
   41 |     std::sort(P,P+n);
      |               ^
teams.cpp:42:13: error: expected ';' before 'j'
   42 |     for(uint j=0,r;j<n;j+=Block)
      |             ^~
      |             ;
teams.cpp:42:20: error: 'j' was not declared in this scope
   42 |     for(uint j=0,r;j<n;j+=Block)
      |                    ^
teams.cpp:42:27: error: 'Block' was not declared in this scope
   42 |     for(uint j=0,r;j<n;j+=Block)
      |                           ^~~~~
teams.cpp:44:9: error: 'F' was not declared in this scope
   44 |         F[j/Block]=P[j].first;
      |         ^
teams.cpp:45:14: error: 'sort' is not a member of 'std'
   45 |         std::sort(P+j,P+(r=std::min(j+Block,n)),
      |              ^~~~
teams.cpp:45:26: error: 'r' was not declared in this scope
   45 |         std::sort(P+j,P+(r=std::min(j+Block,n)),
      |                          ^
teams.cpp:45:33: error: 'min' is not a member of 'std'
   45 |         std::sort(P+j,P+(r=std::min(j+Block,n)),
      |                                 ^~~
teams.cpp:46:17: error: 'std::pair' has not been declared
   46 |             [&](std::pair<uint,uint>a,std::pair<uint,uint>b){return a.second>b.second;}),c++;
      |                 ^~~
teams.cpp:46:26: error: expected ',' or '...' before '<' token
   46 |             [&](std::pair<uint,uint>a,std::pair<uint,uint>b){return a.second>b.second;}),c++;
      |                          ^
teams.cpp: In lambda function:
teams.cpp:46:69: error: 'a' was not declared in this scope
   46 |             [&](std::pair<uint,uint>a,std::pair<uint,uint>b){return a.second>b.second;}),c++;
      |                                                                     ^
teams.cpp:46:78: error: 'b' was not declared in this scope
   46 |             [&](std::pair<uint,uint>a,std::pair<uint,uint>b){return a.second>b.second;}),c++;
      |                                                                              ^
teams.cpp: In function 'int main()':
teams.cpp:46:90: error: 'c' was not declared in this scope
   46 |             [&](std::pair<uint,uint>a,std::pair<uint,uint>b){return a.second>b.second;}),c++;
      |                                                                                          ^
teams.cpp:47:17: error: expected ';' before 'k'
   47 |         for(uint k=0;k<r;k++)C[c][P[k].second]++;
      |                 ^~
      |                 ;
teams.cpp:47:22: error: 'k' was not declared in this scope
   47 |         for(uint k=0;k<r;k++)C[c][P[k].second]++;
      |                      ^
teams.cpp:47:30: error: 'C' was not declared in this scope
   47 |         for(uint k=0;k<r;k++)C[c][P[k].second]++;
      |                              ^
teams.cpp:48:17: error: expected ';' before 'k'
   48 |         for(uint k=n;k;k--)C[c][k-1]+=C[c][k];
      |                 ^~
      |                 ;
teams.cpp:48:22: error: 'k' was not declared in this scope
   48 |         for(uint k=n;k;k--)C[c][k-1]+=C[c][k];
      |                      ^
teams.cpp:48:28: error: 'C' was not declared in this scope
   48 |         for(uint k=n;k;k--)C[c][k-1]+=C[c][k];
      |                            ^
teams.cpp:50:17: error: 'q' was not declared in this scope
   50 |     scanf("%u",&q);
      |                 ^
teams.cpp:53:13: error: expected ';' before 'm'
   53 |         uint m;scanf("%u",&m);
      |             ^~
      |             ;
teams.cpp:53:28: error: 'm' was not declared in this scope
   53 |         uint m;scanf("%u",&m);
      |                            ^
teams.cpp:54:14: error: 'vector' is not a member of 'std'
   54 |         std::vector<uint>S(m);
      |              ^~~~~~
teams.cpp:1:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
  +++ |+#include <vector>
    1 | const uint Block=3000,Lim=500000;
teams.cpp:54:26: error: 'S' was not declared in this scope
   54 |         std::vector<uint>S(m);
      |                          ^
teams.cpp:56:14: error: 'solve' was not declared in this scope
   56 |         puts(solve(S)?"1":"0");
      |              ^~~~~
teams.cpp:56:9: error: 'puts' was not declared in this scope
   56 |         puts(solve(S)?"1":"0");
      |         ^~~~