Submission #1050462

#TimeUsernameProblemLanguageResultExecution timeMemory
1050462TahirAliyevCarnival Tickets (IOI20_tickets)C++17
Compilation error
0 ms0 KiB
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int, int>
#define ll long long

ll find_maximum(int k, std::vector<std::vector<int>> x) {
	int n = x.size();
	int m = x[0].size();
	vector<vector<int>> res;
	res.resize(n);
	for(int i = 0; i < n; i++) res[i].resize(m, -1);
	vector<int> l(n, 0), r(n, m - 1);
	ll ans = 0;
	while(int j = 0; j < k; j++){
		vector<pii> v;
		for(int i = 0; i < n; i++){
			v.push_back({x[i][l[i]] + x[i][r[i]], i});
		}
		sort(v.begin(), v.end());
		for(int i = 0; i < n; i++){
			if(i < n / 2){
				ans -= (x[v[i].second][l[v[i].second]]);
				res[v[i].second][l[v[i].second]] = j;
				l[v[i].second]++;
			}
			else{
				ans += (x[v[i].second][r[v[i].second]]);
				res[v[i].second][r[v[i].second]] = j;
				r[v[i].second]--;
			} 
		}
	}
	allocate_tickets(res);
	return ans;
}

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:16:17: error: expected ')' before ';' token
   16 |  while(int j = 0; j < k; j++){
      |       ~         ^
      |                 )
tickets.cpp:16:2: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   16 |  while(int j = 0; j < k; j++){
      |  ^~~~~
tickets.cpp:16:19: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   16 |  while(int j = 0; j < k; j++){
      |                   ^
tickets.cpp:16:12: warning: unused variable 'j' [-Wunused-variable]
   16 |  while(int j = 0; j < k; j++){
      |            ^
tickets.cpp:16:19: error: 'j' was not declared in this scope
   16 |  while(int j = 0; j < k; j++){
      |                   ^