제출 #307175

#제출 시각아이디문제언어결과실행 시간메모리
307175rrrr10000카니발 티켓 (IOI20_tickets)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(long long i=0;i<(long long)(n);i++) #define REP(i,k,n) for(long long i=k;i<(long long)(n);i++) #define all(a) a.begin(),a.end() #define pb emplace_back #define eb emplace_back #define lb(v,k) (lower_bound(all(v),k)-v.begin()) #define ub(v,k) (upper_bound(all(v),k)-v.begin()) #define fi first #define se second #define pi M_PI #define PQ(T) priority_queue<T> #define SPQ(T) priority_queue<T,vector<T>,greater<T>> #define dame(a) {out(a);return 0;} #define decimal cout<<fixed<<setprecision(15); #define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());} typedef long long ll; typedef pair<ll,ll> P; typedef tuple<ll,ll,ll> PP; typedef tuple<ll,ll,ll,ll> PPP; typedef multiset<ll> S; using vi=vector<ll>; using vvi=vector<vi>; using vvvi=vector<vvi>; using vvvvi=vector<vvvi>; using vp=vector<P>; using vvp=vector<vp>; using vb=vector<bool>; using vvb=vector<vb>; const ll inf=1001001001001001001; const ll INF=1001001001; const ll mod=1000000007; const double eps=1e-10; template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;} template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;} template<class T> void out(T a){cout<<a<<'\n';} template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';} template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';} template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);} template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';} template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);} template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);} template<class T> void yesno(T b){if(b)out("yes");else out("no");} template<class T> void YesNo(T b){if(b)out("Yes");else out("No");} template<class T> void YESNO(T b){if(b)out("YES");else out("NO");} template<class T> void noyes(T b){if(b)out("no");else out("yes");} template<class T> void NoYes(T b){if(b)out("No");else out("Yes");} template<class T> void NOYES(T b){if(b)out("NO");else out("YES");} void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);} ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);} ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;} #include "tickets.h" vector<vector<int>> res; void solve(int k){ ll n=res.size(),m=res[0].size(); vp t(n,P(0,k-1)); vvi id(n); rep(i,n)rep(j,m)if(res[i][j]!=-1)id[i].pb(j); rep(i,k){ ll zero=0,one=0; rep(j,n)if(res[j][id[j][t[j].fi]]==1)one++; rep(j,n){ if(res[j][id[j][t[j].se]]==0||one==n/2){ res[j][id[j][t[j].fi++]]=i; } else{ if(res[j][id[j][t[j].fi]]==0)one++; res[j][id[j][t[j].se--]]=i; } } } } long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); res=vector<vector<int>>(n,vector<int>(m,-1)); ll ans=0; if(k==m){ vector<PP> v; rep(i,n)rep(j,m)v.pb(x[i][j],i,j); sort(all(v)); rep(t,n*m){ ll i,j,a;tie(a,i,j)=v[t]; if(t<n*m/2){ ans-=a; res[i][j]=0; } else{ ans+=a; res[i][j]=1; } } solve(k); } else if(k==1){ vvp dp(n/2+1,vp(n/2+1,P(-inf,0))); dp[0][0]=P(0,0); rep(i,n/2+1)rep(j,n/2+1){ if(i!=n/2)chmax(dp[i+1][j],P(dp[i][j].fi-x[i+j][0],1)); if(j!=n/2)chmax(dp[i][j+1],P(dp[i][j].fi+x[i+j][m-1],0)); } ans=dp[n/2][n/2].fi; ll i=n/2,j=n/2; while(i+j){ if(dp[i][j].se){ i--; res[i+j][0]++; } else{ j--; res[i+j][m-1]++; } } } else if(n<=80&&m<=80){ vvp dp(n+1,vp(k*n/2+1,P(-inf,0))); vvp dp(n/2+1,vp(n/2+1,P(-inf,0))); dp[0][0]=P(0,0); vvi rui(n,vi(k+1)); rep(i,n){ rep(j,k)rui[i][0]+=x[i][m-j-1]; rep(j,k)rui[i][j+1]=rui[i][j]-x[i][j]-x[i][m-j-1]; } rep(i,n)rep(j,dp[i].size())rep(t,min(dp[i].size()-j,k+1)){ chmax(dp[i+1][j+t],P(dp[i][j].fi+rui[i][t],t)); } ans=dp[n][k*n/2].fi; ll i=n,j=k*n/2; while(i){ rep(t,dp[i][j].se)res[i-1][t]=0; rep(t,k-dp[i][j].se)res[i-1][m-t-1]=1; i--; j-=dp[i][j].se; } solve(k); } else{ vi num(n,m); rep(i,n)rep(j,m)if(x[i][j]==1)chmin(num[i],j); vp t(n,P(0,m-1)); rep(i,k){ vp s(n); ll zero=0,one=0; rep(j,n)if(x[j][t[j].fi])one++; rep(j,n)if(!x[j][t[j].se])zero++; if(one>n/2){ ans+=n-one; rep(j,n){ if(x[j][t[j].fi])res[j][t[j].se--]=i; else{ res[j][t[j].fi++]=i; num[j]--; } } } else if(zero>n/2){ ans+=n-zero; rep(j,n){ if(!x[j][t[j].se]){ res[j][t[j].fi++]=i; num[j]--; } else res[j][t[j].se--]=i; } } else{ ans+=n/2; vp s(n); rep(j,n)s[j]=P(num[j],j); sort(all(s)); rep(j,n){ if(x[s[j].se][t[s[j].se].se]==0||one==n/2){ res[s[j].se][t[s[j].se].fi++]=i; num[s[j].se]--; } else{ if(x[s[j].se][t[s[j].se].fi]==0)one++; res[s[j].se][t[s[j].se].se--]=i; } } } } /* ll cnt=0; rep(i,n)rep(j,k)cnt+=x[i][j]; if(cnt>=n*k/2){ ans=n*k-cnt; vp t(n,P(0,k-1)); rep(i,k){ ll zero=0,one=0; rep(j,n)if(x[j][t[j].fi]==1)one++; rep(j,n){ if(x[j][t[j].se]==0||(one==n/2&&x[j][t[j].fi]==0)){ res[j][t[j].fi++]=i; } else{ if(x[j][t[j].fi]==0)one++; res[j][t[j].se--]=i; } } } } else{ cnt=0; rep(i,n)rep(j,k)cnt+=x[i][m-j-1]; if(cnt<=n*k/2){ ans=cnt; vp t(n,P(m-k,m-1)); rep(i,k){ ll zero=0,one=0; rep(j,n)if(x[j][t[j].se]==0)zero++; rep(j,n){ if(x[j][t[j].fi]==1||(zero==n/2&&x[j][t[j].se]==1)){ res[j][t[j].se--]=i; } else{ if(x[j][t[j].se]==1)zero++; res[j][t[j].fi++]=i; } } } } else{ ans=n*k/2; vp t(n,P(0,m-1)); rep(i,k){ ll zero=0,one=0; rep(j,n)if(x[j][t[j].fi]==1)one++; rep(j,n){ if(x[j][t[j].se]==0||one==n/2){ res[j][t[j].fi++]=i; } else{ if(x[j][t[j].fi]==0)one++; res[j][t[j].se--]=i; } } } } }*/ } allocate_tickets(res); return ans; }

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

tickets.cpp: In function 'void solve(int)':
tickets.cpp:62:12: warning: unused variable 'zero' [-Wunused-variable]
   62 |         ll zero=0,one=0;
      |            ^~~~
tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:119:13: error: redeclaration of 'vvp dp'
  119 |         vvp dp(n/2+1,vp(n/2+1,P(-inf,0)));
      |             ^~
tickets.cpp:118:13: note: 'vvp dp' previously declared here
  118 |         vvp dp(n+1,vp(k*n/2+1,P(-inf,0)));
      |             ^~
tickets.cpp:126:64: error: no matching function for call to 'min(long long unsigned int, int)'
  126 |         rep(i,n)rep(j,dp[i].size())rep(t,min(dp[i].size()-j,k+1)){
      |                                                                ^
tickets.cpp:3:52: note: in definition of macro 'rep'
    3 | #define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
      |                                                    ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
tickets.cpp:126:64: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'int')
  126 |         rep(i,n)rep(j,dp[i].size())rep(t,min(dp[i].size()-j,k+1)){
      |                                                                ^
tickets.cpp:3:52: note: in definition of macro 'rep'
    3 | #define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
      |                                                    ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
tickets.cpp:126:64: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'int')
  126 |         rep(i,n)rep(j,dp[i].size())rep(t,min(dp[i].size()-j,k+1)){
      |                                                                ^
tickets.cpp:3:52: note: in definition of macro 'rep'
    3 | #define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
      |                                                    ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
tickets.cpp:126:64: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
  126 |         rep(i,n)rep(j,dp[i].size())rep(t,min(dp[i].size()-j,k+1)){
      |                                                                ^
tickets.cpp:3:52: note: in definition of macro 'rep'
    3 | #define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
      |                                                    ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
tickets.cpp:126:64: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
  126 |         rep(i,n)rep(j,dp[i].size())rep(t,min(dp[i].size()-j,k+1)){
      |                                                                ^
tickets.cpp:3:52: note: in definition of macro 'rep'
    3 | #define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
      |                                                    ^