Submission #501055

#TimeUsernameProblemLanguageResultExecution timeMemory
501055Koosha_mvOlympiads (BOI19_olympiads)C++14
100 / 100
585 ms43264 KiB
#include <bits/stdc++.h> using namespace std; #define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl #define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl #define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl #define eror(x) cout<<#x<<'='<<(x)<<endl #define f_(i,a,b) for(int i=a;i>=b;i--) #define f(i,a,b) for(int i=a;i<b;i++) #define nb(x) __builtin_popcount(x) #define all(v) v.begin(),v.end() #define bit(n,k) (((n)>>(k))&1) #define Add(x,y) x=(x+y)%mod #define maxm(a,b) a=max(a,b) #define minm(a,b) a=min(a,b) #define lst(x) x[x.size()-1] #define sz(x) int(x.size()) #define mp make_pair #define ll long long #define pb push_back #define S second #define F first #define int ll const int N=505,K=6; int n,k,C,a[N][K],mark[N],res[N*N*4]; pair<int,int> Max[K]; vector<pair<int,int> > mv; vector<vector<int> > v,newv; void reset(){ f(i,0,k){ Max[i]={-1,-1}; } } void op(int x){ f(i,0,k){ maxm(Max[i],mp(a[x][i],x)); } } int Sum(){ int res=0; f(i,0,k){ res+=Max[i].F; } return res; } int Count(vector<int> &v){ int ans=0; f(i,0,v.size()) if(++mark[v[i]]==1) ans++; f(i,0,v.size()) mark[v[i]]--; return ans; } void do_it(vector<int> v,int x){ vector<pair<int,int> > e; reset(); for(auto x : v){ op(x); } f(i,0,n){ int check=1; f(j,0,x){ if(mp(a[i][j],i)>Max[j]){ check=0; } } if(check==1){ e.pb(mp(a[i][x],i)); } } sort(all(e)); f(i,0,e.size()){ op(e[i].S); if(e[i]>=Max[x]){ vector<int> vec=v; vec.pb(e[i].S); if(Count(vec)+i>=k){ mv.pb(mp(Sum(),newv.size())); newv.pb(vec); } } } } int calc(vector<int> v){ int cnt=0,res=1,need=k-Count(v); reset(); f(i,0,v.size()){ op(v[i]); } cout<<endl; f(i,0,n){ int check=1; f(j,0,k){ if(mp(a[i][j],i)>=Max[j]){ check=0; } } cnt+=check; } f(i,1,need+1){ res=res*(cnt-i+1); res/=i; } return res; } main(){ cin>>n>>k>>C; f(i,0,n){ f(j,0,k){ cin>>a[i][j]; } } vector<int > temp; v.pb(temp); f(i,0,k){ mv.clear(); newv.clear(); for(auto x : v){ do_it(x,i); } v.clear(); sort(all(mv),greater<pair<int,int> >()); int sz=min(C,(ll) mv.size()); f(j,0,sz){ if(v.size()==j) v.pb(temp); v[j]=newv[mv[j].S]; } } f(i,0,v.size()){ C-=calc(v[i]); if(C<=0){ cout<<Sum(); exit(0); } } }

Compilation message (stderr)

olympiads.cpp: In function 'long long int Count(std::vector<long long int>&)':
olympiads.cpp:8:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   50 |  f(i,0,v.size()) if(++mark[v[i]]==1) ans++;
      |    ~~~~~~~~~~~~                
olympiads.cpp:50:2: note: in expansion of macro 'f'
   50 |  f(i,0,v.size()) if(++mark[v[i]]==1) ans++;
      |  ^
olympiads.cpp:8:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   51 |  f(i,0,v.size()) mark[v[i]]--;
      |    ~~~~~~~~~~~~                
olympiads.cpp:51:2: note: in expansion of macro 'f'
   51 |  f(i,0,v.size()) mark[v[i]]--;
      |  ^
olympiads.cpp: In function 'void do_it(std::vector<long long int>, long long int)':
olympiads.cpp:8:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   72 |  f(i,0,e.size()){
      |    ~~~~~~~~~~~~                
olympiads.cpp:72:2: note: in expansion of macro 'f'
   72 |  f(i,0,e.size()){
      |  ^
olympiads.cpp: In function 'long long int calc(std::vector<long long int>)':
olympiads.cpp:8:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   87 |  f(i,0,v.size()){
      |    ~~~~~~~~~~~~                
olympiads.cpp:87:2: note: in expansion of macro 'f'
   87 |  f(i,0,v.size()){
      |  ^
olympiads.cpp: At global scope:
olympiads.cpp:107:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  107 | main(){
      | ^~~~
olympiads.cpp: In function 'int main()':
olympiads.cpp:126:15: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
  126 |    if(v.size()==j) v.pb(temp);
      |       ~~~~~~~~^~~
olympiads.cpp:8:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
  130 |  f(i,0,v.size()){
      |    ~~~~~~~~~~~~                
olympiads.cpp:130:2: note: in expansion of macro 'f'
  130 |  f(i,0,v.size()){
      |  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...