제출 #307162

#제출 시각아이디문제언어결과실행 시간메모리
307162rrrr10000카니발 티켓 (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" long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> res(n,vector<int>(m)); 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; else{ ans+=a; res[i][j]=1; } } vp t(n,P(0,m-1)); rep(i,m){ ll zero=0,one=0; rep(j,n)if(res[j][t[j].fi]==1)one++; rep(j,n){ if(res[j][t[j].se]==0||one==n/2){ res[j][t[j].fi++]=i; } else{ if(res[j][t[j].fi]==0)one++; res[j][t[j].se--]=i; } } } } 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)); } rep(i,n)rep(j,m)res[i][j]=-1; 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{ rep(i,n)rep(j,m)res[i][j]=-1; vi num(n,m); rep(i,n)rep(j,m)if(v[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(zero>n/2){ ans+=n-zero; rep(j,n){ if(!x[j][t[j].se])res[j][t[j].se--]=i; else{ res[j][t[j].fi++]=i; num[j]--; } } } else if(one>n/2){ ans+=n-one; rep(j,n){ if(x[j][t[j].fi]){ 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)); if(res[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(res[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 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:75:16: warning: unused variable 'zero' [-Wunused-variable]
   75 |             ll zero=0,one=0;
      |                ^~~~
tickets.cpp:112:28: error: 'v' was not declared in this scope
  112 |         rep(i,n)rep(j,m)if(v[i][j]==1)chmin(num[i],j);
      |                            ^
tickets.cpp:144:26: error: 'j' was not declared in this scope
  144 |                 if(res[s[j].se][t[s[j].se].se]==0||one==n/2){
      |                          ^