Submission #363657

#TimeUsernameProblemLanguageResultExecution timeMemory
363657Sparky_09Carnival Tickets (IOI20_tickets)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define trav(a, x) for(auto& a : x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<ll, ll> pii; typedef vector<ll> vi; typedef vector<pii> vpi; void usaco(string s){ freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } int n,m; const ll N = 2e3+100; ll t[N]; struct node{ ll num,val; }a[N]; ll cmp(node a,node b){ return a.val < b.val; } long long find_maximum(int k, vector<vector<int>> x) { n = x.size(); m = x[0].size(); vector<vector<int>> ans(n, vector<int>(m, -1)); if(m == 1){ for(int i = 0; i < n; i++) ans[i][0]=0; allocate_tickets(ans); ll s = 0; for(int i = 0; i < n; i++) t[i] = x[i][0]; sort(t, t+n); for(int i = 0;i < n/2; i++) s -= t[i]; for(int i = n/2; i < n; i++) s += t[i]; return s; } else(k == 1){ ll s = 0; for(int i = 0; i < n; i++) s += x[i][n-1]; for(int i = 0; i < n; i++) a[i] = (node){i,x[i][0]+x[i][n-1]}; sort(a , a+n, cmp); for(int i = 0; i < n/2; i++) s -= a[i].val, ans[a[i].num][0] = 0; for(int i= n/2 ;i < n; i++) ans[a[i].num][n-1]=0; allocate_tickets(ans); return s; } }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:36:3: error: 'allocate_tickets' was not declared in this scope
   36 |   allocate_tickets(ans);
      |   ^~~~~~~~~~~~~~~~
tickets.cpp:47:14: error: expected ';' before '{' token
   47 |  else(k == 1){
      |              ^
      |              ;
tickets.cpp: In function 'void usaco(std::string)':
tickets.cpp:13:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   13 |   freopen((s+".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tickets.cpp:14:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   14 |   freopen((s+".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:32:47: warning: control reaches end of non-void function [-Wreturn-type]
   32 |  vector<vector<int>> ans(n, vector<int>(m, -1));
      |                                               ^