제출 #366935

#제출 시각아이디문제언어결과실행 시간메모리
366935wind_reaper카니발 티켓 (IOI20_tickets)C++17
컴파일 에러
0 ms0 KiB
#include "tickets.h"
#include <bits/stdc++.h>

using namespace std;

long long find_maximum(int k, vector<vector<int>> x) {
	int n = x.size(); 
	int m = x[0].size();
 
	vector<vector<int>> ans(n, vector<int>(m, -1));
 
	int64_t a = 0;
 
	for(int i = 0; i < n; i++){
		for(int j = m-1; j >= m-k; --j){
			ans[i][j] = (m-1-j);
			a += int64_t(x[i][j]);
		}
	}
 
	vector<array<int64_t, 4>> b;

	for(int i = 0; i < n; i++){
		for(int j = 1; j <= k; j++)
			b.push_back({x[i][k-j] + x[i][m-j], i, k-j, m-j});
	}

	sort(b.rbegin(), b.rend());

 	for(int i = 0; i < (n*k)/2; i++){
 		int64_t red = b[i][0];
 		int row = b[i][1], mn = b[i][2], b[i][3];
 		a -= red;
 		swap(ans[row][mx], ans[row][mn]);
 	}
	allocate_tickets(ans);
	return a;
}

컴파일 시 표준 에러 (stderr) 메시지

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:34:18: error: 'mx' was not declared in this scope; did you mean 'mn'?
   34 |    swap(ans[row][mx], ans[row][mn]);
      |                  ^~
      |                  mn
tickets.cpp:32:37: warning: unused variable 'b' [-Wunused-variable]
   32 |    int row = b[i][1], mn = b[i][2], b[i][3];
      |                                     ^