Submission #428712

#TimeUsernameProblemLanguageResultExecution timeMemory
428712davi_bartCarnival Tickets (IOI20_tickets)C++17
11 / 100
4 ms3788 KiB
#include "tickets.h" #pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define int ll #define fi first #define se second #define ld long double #define pb push_back vector<std::vector<signed>> ans; bool vis[2000][2000]; int presi[2000]; int N,M; vector<int> x[2000],y[2000]; vector<int> start(2001); long long find_maximum(signed k, std::vector<std::vector<signed>> z) { N = z.size(); M = z[0].size(); vector<tuple<int,int,int> >v; for(int i=0;i<N;i++){ for(int j=0;j<M;j++){ v.pb({z[i][j],i,j}); } } sort(v.begin(),v.end()); vector<pair<int,int> > ma,mi; int tot=0; for(int i=0;i<v.size();i++){ auto [a,b,c]=v[i]; if(presi[b]==k)continue; if(vis[b][c])continue; presi[b]++; vis[b][c]=1; mi.pb({b,c}); tot-=a; if(mi.size()==N/2*k)break; } for(int i=v.size()-1;i>=0;i--){ auto [a,b,c]=v[i]; if(presi[b]==k)continue; if(vis[b][c])continue; presi[b]++; vis[b][c]=1; ma.pb({b,c}); tot+=a; if(ma.size()==N/2*k)break; } for (int i=0;i<N;i++) { vector<signed> row(M,-1); ans.pb(row); } for(auto [a,b]:mi)x[a].pb(b); for(auto [a,b]:ma)y[a].pb(b); int pos=0; for(int i=0;i<N;i++){ start[i]=pos; for(int j=0;j<x[i].size();j++){ ans[i][x[i][j]]=pos; pos=(pos+1)%k; } } for(int i=0;i<N;i++){ pos=(start[i]+1)%k; for(int j=0;j<y[i].size();j++){ ans[i][y[i][j]]=pos; pos=(pos+1)%k; } } allocate_tickets(ans); return tot; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:30:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::tuple<long long int, long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
tickets.cpp:38:21: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   38 |         if(mi.size()==N/2*k)break;
      |            ~~~~~~~~~^~~~~~~
tickets.cpp:48:21: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   48 |         if(ma.size()==N/2*k)break;
      |            ~~~~~~~~~^~~~~~~
tickets.cpp:63:22: 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]
   63 |         for(int j=0;j<x[i].size();j++){
      |                     ~^~~~~~~~~~~~
tickets.cpp:70:22: 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]
   70 |         for(int j=0;j<y[i].size();j++){
      |                     ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...