제출 #134211

#제출 시각아이디문제언어결과실행 시간메모리
134211dvdg6566Olympiads (BOI19_olympiads)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef vector<int> vi; typedef vector<pi> vpi; #define pb emplace_back #define mp make_pair #define f first #define s second #define lb lower_bound #define ub upper_bound #define ALL(X) X.begin(),X.end() #define SZ(X) (int)X.size() #define MAXN 1001000 #define INF 1e9 int N,K,C; int mem[510][10]; vi cur; set<pi> st; vi out; int cntr; int lefts[2010][4]; int rights[2010][4]; bitset<21000000> safe; int ind; map<ll,int> M; ll hh(){ ll ans=0;ll mult = 1; while(SZ(cur)){ ans += mult * cur.back(); cur.pop_back(); mult *= N; } return ans; } void rec2(int stt, int en){ if (SZ(cur) == en-stt+1){ ++cntr; int ans = 0; // for (auto i : cur)cout<<i<<' ';cout<<'\n'; for (int i=stt;i<en;++i){ int t=0; for (int j=1;j<SZ(cur);++j)t=max(t,mem[cur[j]][i]); ans += t; } // cout<<ans<<'\n'; st.insert(mp(ans,cntr)); if (SZ(st) > C)st.erase(st.begin()); return; } int lst = cur.back()+1; for (int i=lst;i<=N;++i){ cur.pb(i); rec2(stt,en); cur.pop_back(); } } void rec3(int stt, int en, bool flag){ if (SZ(cur) == en-stt+1){ ++cntr; // cout<<cntr<<' '<<safe[cntr]<<'\n'; if (safe[cntr] == 0)return; int ans = 0; for (int i=1;i<SZ(cur);++i){ if (flag)lefts[ind][i-1] = cur[i]; else rights[ind][i-1] = cur[i]; } ++ind; return; } int lst = cur.back()+1; for (int i=lst;i<=N;++i){ cur.pb(i); rec3(stt,en,flag); cur.pop_back(); } } int main(){ // freopen("in.txt","r",stdin); cin>>N>>K>>C; for (int i=1;i<=N;++i)for (int j=0;j<K;++j)cin>>mem[i][j]; cur.pb(0); rec2(0,K/2); for (auto i :st)safe[i.s]=1; cntr=0; rec3(0,K/2,1); cntr=ind=0; while(SZ(st))st.erase(st.begin()); safe.reset(); // cout<<K/2<<' '<<K<<'\n'; rec2(K/2,K); // for (auto i : st)cout<<i.f<<' '<<i.s<<'\n'; for (auto i :st)safe[i.s]=1; cntr=0; rec3(K/2,K,0); // return 0; // for (int i=0;i<C;++i)cout<<lefts[i][0]<<' '<<lefts[i][1]<<' '<<lefts[i][2]<<'\n'; for (int i=0;i<C;++i){ if (lefts[i][0] == 0)break; for (int j=0;j<C;++j){ if (rights[j][0] ==0)break; cur.clear(); cur.pb(lefts[i][0]); if (lefts[i][1] != 0)cur.pb(lefts[i][1]); if (lefts[i][2] != 0)cur.pb(lefts[i][2]); cur.pb(rights[j][0]); if (rights[j][1] != 0)cur.pb(rights[j][1]); if (rights[j][2] != 0)cur.pb(rights[j][2]); sort(ALL(cur)); cur.resize(unique(ALL(cur)) - cur.begin()); if (SZ(cur) < K)continue; // for (auto x:cur)cout<<x<<' ';cout<<'\n'; int ans=0; for (int i=0;i<K;++i){ int t=0; for (int j=0;j<SZ(cur);++j)t=max(t,mem[cur[j]][i]); ans += t; } M[hh()]=ans; } } for (auto i : M)out.pb(i.s); sort(ALL(out)); cout<<out[SZ(out) - C]; }#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef vector<int> vi; typedef vector<pi> vpi; #define pb emplace_back #define mp make_pair #define f first #define s second #define lb lower_bound #define ub upper_bound #define ALL(X) X.begin(),X.end() #define SZ(X) (int)X.size() #define MAXN 1001000 #define INF 1e9 int N,K,C; int mem[510][10]; vi cur; set<pi> st; vi out; int cntr; int lefts[2010][4]; int rights[2010][4]; bitset<21000000> safe; int ind; map<ll,int> M; ll hh(){ ll ans=0;ll mult = 1; while(SZ(cur)){ ans += mult * cur.back(); cur.pop_back(); mult *= N; } return ans; } void rec2(int stt, int en){ if (SZ(cur) == en-stt+1){ ++cntr; int ans = 0; // for (auto i : cur)cout<<i<<' ';cout<<'\n'; for (int i=stt;i<en;++i){ int t=0; for (int j=1;j<SZ(cur);++j)t=max(t,mem[cur[j]][i]); ans += t; } // cout<<ans<<'\n'; st.insert(mp(ans,cntr)); if (SZ(st) > C)st.erase(st.begin()); return; } int lst = cur.back()+1; for (int i=lst;i<=N;++i){ cur.pb(i); rec2(stt,en); cur.pop_back(); } } void rec3(int stt, int en, bool flag){ if (SZ(cur) == en-stt+1){ ++cntr; // cout<<cntr<<' '<<safe[cntr]<<'\n'; if (safe[cntr] == 0)return; int ans = 0; for (int i=1;i<SZ(cur);++i){ if (flag)lefts[ind][i-1] = cur[i]; else rights[ind][i-1] = cur[i]; } ++ind; return; } int lst = cur.back()+1; for (int i=lst;i<=N;++i){ cur.pb(i); rec3(stt,en,flag); cur.pop_back(); } } int main(){ // freopen("in.txt","r",stdin); cin>>N>>K>>C; for (int i=1;i<=N;++i)for (int j=0;j<K;++j)cin>>mem[i][j]; cur.pb(0); rec2(0,K/2); for (auto i :st)safe[i.s]=1; cntr=0; rec3(0,K/2,1); cntr=ind=0; while(SZ(st))st.erase(st.begin()); safe.reset(); // cout<<K/2<<' '<<K<<'\n'; rec2(K/2,K); // for (auto i : st)cout<<i.f<<' '<<i.s<<'\n'; for (auto i :st)safe[i.s]=1; cntr=0; rec3(K/2,K,0); // return 0; // for (int i=0;i<C;++i)cout<<lefts[i][0]<<' '<<lefts[i][1]<<' '<<lefts[i][2]<<'\n'; for (int i=0;i<C;++i){ if (lefts[i][0] == 0)break; for (int j=0;j<C;++j){ if (rights[j][0] ==0)break; cur.clear(); cur.pb(lefts[i][0]); if (lefts[i][1] != 0)cur.pb(lefts[i][1]); if (lefts[i][2] != 0)cur.pb(lefts[i][2]); cur.pb(rights[j][0]); if (rights[j][1] != 0)cur.pb(rights[j][1]); if (rights[j][2] != 0)cur.pb(rights[j][2]); sort(ALL(cur)); cur.resize(unique(ALL(cur)) - cur.begin()); if (SZ(cur) < K)continue; // for (auto x:cur)cout<<x<<' ';cout<<'\n'; int ans=0; for (int i=0;i<K;++i){ int t=0; for (int j=0;j<SZ(cur);++j)t=max(t,mem[cur[j]][i]); ans += t; } M[hh()]=ans; } } for (auto i : M)out.pb(i.s); sort(ALL(out)); cout<<out[SZ(out) - C]; }

컴파일 시 표준 에러 (stderr) 메시지

olympiads.cpp:136:2: error: stray '#' in program
 }#include<bits/stdc++.h>
  ^
olympiads.cpp: In function 'void rec3(int, int, bool)':
olympiads.cpp:69:13: warning: unused variable 'ans' [-Wunused-variable]
         int ans = 0;
             ^~~
olympiads.cpp: At global scope:
olympiads.cpp:136:3: error: 'include' does not name a type
 }#include<bits/stdc++.h>
   ^~~~~~~
olympiads.cpp:153:5: error: redefinition of 'int N'
 int N,K,C;
     ^
olympiads.cpp:18:5: note: 'int N' previously declared here
 int N,K,C;
     ^
olympiads.cpp:153:7: error: redefinition of 'int K'
 int N,K,C;
       ^
olympiads.cpp:18:7: note: 'int K' previously declared here
 int N,K,C;
       ^
olympiads.cpp:153:9: error: redefinition of 'int C'
 int N,K,C;
         ^
olympiads.cpp:18:9: note: 'int C' previously declared here
 int N,K,C;
         ^
olympiads.cpp:154:16: error: redefinition of 'int mem [510][10]'
 int mem[510][10];
                ^
olympiads.cpp:19:5: note: 'int mem [510][10]' previously declared here
 int mem[510][10];
     ^~~
olympiads.cpp:155:4: error: redefinition of 'vi cur'
 vi cur;
    ^~~
olympiads.cpp:20:4: note: 'vi cur' previously declared here
 vi cur;
    ^~~
olympiads.cpp:157:9: error: redefinition of 'std::set<std::pair<int, int> > st'
 set<pi> st;
         ^~
olympiads.cpp:22:9: note: 'std::set<std::pair<int, int> > st' previously declared here
 set<pi> st;
         ^~
olympiads.cpp:158:4: error: redefinition of 'vi out'
 vi out;
    ^~~
olympiads.cpp:23:4: note: 'vi out' previously declared here
 vi out;
    ^~~
olympiads.cpp:159:5: error: redefinition of 'int cntr'
 int cntr;
     ^~~~
olympiads.cpp:24:5: note: 'int cntr' previously declared here
 int cntr;
     ^~~~
olympiads.cpp:160:18: error: redefinition of 'int lefts [2010][4]'
 int lefts[2010][4];
                  ^
olympiads.cpp:25:5: note: 'int lefts [2010][4]' previously declared here
 int lefts[2010][4];
     ^~~~~
olympiads.cpp:161:19: error: redefinition of 'int rights [2010][4]'
 int rights[2010][4];
                   ^
olympiads.cpp:26:5: note: 'int rights [2010][4]' previously declared here
 int rights[2010][4];
     ^~~~~~
olympiads.cpp:162:18: error: redefinition of 'std::bitset<21000000> safe'
 bitset<21000000> safe;
                  ^~~~
olympiads.cpp:27:18: note: 'std::bitset<21000000> safe' previously defined here
 bitset<21000000> safe;
                  ^~~~
olympiads.cpp:163:5: error: redefinition of 'int ind'
 int ind;
     ^~~
olympiads.cpp:28:5: note: 'int ind' previously declared here
 int ind;
     ^~~
olympiads.cpp:164:13: error: redefinition of 'std::map<long long int, int> M'
 map<ll,int> M;
             ^
olympiads.cpp:29:13: note: 'std::map<long long int, int> M' previously declared here
 map<ll,int> M;
             ^
olympiads.cpp: In function 'll hh()':
olympiads.cpp:166:4: error: redefinition of 'll hh()'
 ll hh(){
    ^~
olympiads.cpp:31:4: note: 'll hh()' previously defined here
 ll hh(){
    ^~
olympiads.cpp: In function 'void rec2(int, int)':
olympiads.cpp:176:6: error: redefinition of 'void rec2(int, int)'
 void rec2(int stt, int en){
      ^~~~
olympiads.cpp:41:6: note: 'void rec2(int, int)' previously defined here
 void rec2(int stt, int en){
      ^~~~
olympiads.cpp: In function 'void rec3(int, int, bool)':
olympiads.cpp:199:6: error: redefinition of 'void rec3(int, int, bool)'
 void rec3(int stt, int en, bool flag){
      ^~~~
olympiads.cpp:64:6: note: 'void rec3(int, int, bool)' previously defined here
 void rec3(int stt, int en, bool flag){
      ^~~~
olympiads.cpp:204:13: warning: unused variable 'ans' [-Wunused-variable]
         int ans = 0;
             ^~~
olympiads.cpp: In function 'int main()':
olympiads.cpp:222:5: error: redefinition of 'int main()'
 int main(){
     ^~~~
olympiads.cpp:87:5: note: 'int main()' previously defined here
 int main(){
     ^~~~