Submission #1124131

#TimeUsernameProblemLanguageResultExecution timeMemory
1124131epicci23Carnival Tickets (IOI20_tickets)C++17
Compilation error
0 ms0 KiB
#include "tickets.h" #include "bits/stdc++.h" using namespace std; long long find_maximum(int k, vector<vector<int>> x) { long long n = x.size(),m = x[0].size(),tot = 0; vector<vector<int>> ans(n,vector<int>(m,-1)); priority_queue<array<long long,2>> pq; vector<long long> p(n,1); for(int i=0;i<n;i++) pq.push({x[i][k-p[i]]+x[i][m-p[i]],i}); for(int i=0;i<k*n/2;i++){ array<long long,2> u = pq.top(); pq.pop(); tot += u[0]; long long ind = u[1]; p[ind]++; pq.push({x[ind][k-p[ind]]+x[ind][m-p[ind]],ind}); } vector<long long> lf(n); for(int i=0;i<n;i++) lf[i]=p[i]-1; array<long long,2> tag[n]; for(int i=0;i<n;i++) tag[i]={0,0}; for(int i=0;i<k;i++){ vector<array<long long,2>> v; for(int j=0;j<n;j++) v.push_back({lf[j],j}); sort(v.begin(),v.end()); reverse(v.begin(),v.end()); vector<long long> vals; for(int j=0;j<n;j++){ long long ind = v[j][1]; if(j<n/2){ lf[ind]--; tag[ind][1]++; ans[ind][m-tag[ind][1]]=i; vals.push_back(x[ind][m-tag[ind][1]]); } else{ vals.push_back(x[ind][tag[ind][0]]); ans[ind][tag[ind][0]]=i; tag[ind][0]++; } } sort(all(vals)); for(int j=0;j<n;j++){ if(j<n/2) tot -= vals[j]; else tot += vals[j]; } } 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:47:12: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   47 |       sort(all(vals));
      |            ^~~
      |            std::filesystem::perms::all
In file included from /usr/include/c++/11/filesystem:44,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:129,
                 from tickets.cpp:2:
/usr/include/c++/11/bits/fs_fwd.h:154:7: note: 'std::filesystem::perms::all' declared here
  154 |       all               =  0777,
      |       ^~~