제출 #336851

#제출 시각아이디문제언어결과실행 시간메모리
336851chenwz카니발 티켓 (IOI20_tickets)C++14
컴파일 에러
0 ms0 KiB
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include "tickets.h"
using namespace std;
typedef long long LL;
const int maxn = 1505;

typedef vector<int> Ivec;
extern "C" void allocate_tickets(std::vector<std::vector<int> > s);

int n, m;
struct Node {
	LL val;
	int id, col;
	bool operator < (const Node& rhs) const {
		return val > rhs.val;
	}
};
int ansL[maxn], cntR[maxn], pos[maxn];
bool cmp(int a, int b) {return ansL[a] > ansL[b];}
LL find_maximum(int K, vector<Ivec> a){
	priority_queue<Node> q;
	n = a.size(), m = a[0].size();
	for (int i = 0; i < n; ++i) q.push((Node) {a[i][0] + a[i][m - K], 0, i});
	int cnt = n * K / 2;
	for (int i = 1; i <= cnt; ++i)
	{
		Node tp = q.top(); q.pop();
		int id = tp.id + 1, col = tp.col;
		if (id == K) ansL[col] = K;
		else q.push((Node) {a[col][id] + a[col][m - K + id], id, col});
	}
	while (!q.empty()) ansL[q.top().col] = q.top().id, q.pop();
	LL ans = 0;
	vector<Ivec> g(n, Ivec(m, -1));
	for (int i = 0; i < n; ++i) pos[i] = i;
	for (int k = 0; k < K; ++k)
	{
		sort(pos, pos + n, cmp);
//		sort(pos, pos + n, [&](int a, int b) {return ansL[a] > ansL[b];});  //洛谷的交互题评测机不让用lambda表达式……
		for (int i = 0; i < n; ++i)
		{
			int p = pos[i];
			if (i < (n >> 1)) g[p][--ansL[p]] = k, ans -= a[p][ansL[p]];
			else g[p][m - (++cntR[p])] = k, ans += a[p][m - cntR[p]];
		}
	}
	allocate_tickets(g);
	return ans;
}

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

tickets.cpp:13:17: error: conflicting declaration of 'void allocate_tickets(std::vector<std::vector<int> >)' with 'C' linkage
   13 | extern "C" void allocate_tickets(std::vector<std::vector<int> > s);
      |                 ^~~~~~~~~~~~~~~~
In file included from tickets.cpp:7:
tickets.h:4:6: note: previous declaration with 'C++' linkage
    4 | void allocate_tickets( std::vector<std::vector<int>> _x);
      |      ^~~~~~~~~~~~~~~~