Submission #1110973

#TimeUsernameProblemLanguageResultExecution timeMemory
1110973modwweTeams (IOI15_teams)C++17
0 / 100
367 ms57116 KiB
//https://www.instagram.com/_modwwe/ #pragma GCC optimize("Ofast,unroll-loops") #include<bits/stdc++.h> //#define int long long #define ll long long #define down cout<<'\n'; #define debug cout<<" cucuucucuuu",down #define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); #define modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".out","w",stdout) #define pb push_back #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; void phongbeo(); const int inf=1e18; const int mod2=1e9+7; const int mod1=998244353; struct icd { long double a; int b; }; struct ib { ll a; ll b; }; struct ic { int a,b,c; }; struct id { int a,b,c,d; }; struct ie { int a,b,c,d,e; }; int n,m,s1,s2,s4,s3,sf,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid; int i,s10,s12; int kk; int el=29; ib a[500002]; int dp[1001]; struct fenwick_2d{ vector<int> bit[500001]; void fake_upd(int x,int y) { for(x;x<=n;x+=x&-x) bit[x].pb(y); } void setup() { for(int i=1;i<=n;i++) sort(bit[i].begin(),bit[i].end()); } int get(int x,int y) {int s=0; for(x;x;x-=x&-x) s=s-(lower_bound(bit[x].begin(),bit[x].end(),y)-bit[x].begin()-1), s+=bit[x].size(); return s; } }fen; vector<int> v; int c[500002]; int can(int M,int K[]) { m=M; for(auto x:v) c[x]=0; v.clear(); for(int i=1;i<=m;i++) { l=K[i-1]; if(!c[l]) v.pb(l); c[l]++; } sort(v.begin(),v.end()); v.pb(n+1); m=v.size()-1; s5=1; for(int i=0;i<m;i++) { s4=fen.get(v[i],v[i]); s9=s4; s10=0; bool de=0; for(int j=i;j<m;j++) { s8=fen.get(v[i],v[j+1]); s9=s9-s8-dp[j]; s10+=dp[j]; if(s4-s8-s10>=v[i]*c[v[i]]) { s1=s4-s8-s10-v[i]*c[v[i]]; dp[j]+=s9-s1; de=1; break; } else { dp[j]+=s9; } s9=s8; } if(!de){s5=0; break;} } for(int i=0;i<m;i++) dp[i]=0; return s5; } void init(int N, int A[], int B[]) { n=N; for(int i=0;i<n;i++) fen.fake_upd(A[i],B[i]); }

Compilation message (stderr)

teams.cpp:19:15: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   19 | const int inf=1e18;
      |               ^~~~
teams.cpp: In member function 'void fenwick_2d::fake_upd(int, int)':
teams.cpp:58:11: warning: statement has no effect [-Wunused-value]
   58 |       for(x;x<=n;x+=x&-x)
      |           ^
teams.cpp: In member function 'void fenwick_2d::setup()':
teams.cpp:63:16: warning: declaration of 'i' shadows a global declaration [-Wshadow]
   63 |        for(int i=1;i<=n;i++)
      |                ^
teams.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
teams.cpp: In member function 'int fenwick_2d::get(int, int)':
teams.cpp:68:19: warning: statement has no effect [-Wunused-value]
   68 |               for(x;x;x-=x&-x)
      |                   ^
teams.cpp:69:20: warning: conversion from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'} to 'int' may change value [-Wconversion]
   69 |                 s=s-(lower_bound(bit[x].begin(),bit[x].end(),y)-bit[x].begin()-1),
      |                   ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
teams.cpp:70:32: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   70 |                 s+=bit[x].size();
      |                                ^
teams.cpp: In function 'int can(int, int*)':
teams.cpp:82:11: warning: declaration of 'i' shadows a global declaration [-Wshadow]
   82 |   for(int i=1;i<=m;i++)
      |           ^
teams.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
teams.cpp:90:13: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   90 |   m=v.size()-1;
      |     ~~~~~~~~^~
teams.cpp:92:14: warning: declaration of 'i' shadows a global declaration [-Wshadow]
   92 |      for(int i=0;i<m;i++)
      |              ^
teams.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
teams.cpp:118:14: warning: declaration of 'i' shadows a global declaration [-Wshadow]
  118 |      for(int i=0;i<m;i++)
      |              ^
teams.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
teams.cpp: In function 'void init(int, int*, int*)':
teams.cpp:125:13: warning: declaration of 'i' shadows a global declaration [-Wshadow]
  125 |     for(int i=0;i<n;i++)
      |             ^
teams.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...