Submission #375453

# Submission time Handle Problem Language Result Execution time Memory
375453 2021-03-09T12:24:14 Z Seanliu Meetings (JOI19_meetings) C++17
Compilation error
0 ms 0 KB
#include "meetings.h"
#include <iostream>
#include <unordered_map>	
#include <algorithm>
#include <vector>
using namespace std;
 
const int maxN = 2e3 + 326;
vector<int> adj[maxN];

void addEdge(int a, int b){
	//cout << "Adding: " << a << ", " << b << endl;
	if(a > b) Bridge(b, a);
	else Bridge(a, b);
}
 
void solve(vector<int> vec){
	if(vec.size() == 1) return;
	if(vec.size() == 2){
		addEdge(vec[0], vec[1]);
		return;
	}
	//cout << "vec = "; for(int x : vec) cout << x << " "; cout << endl;
	map<int, vector<int>> mp;
	vector<int> nv = vector<int>();
	int a = vec[0], b = vec[1];
	for(int i = 2; i < vec.size(); i++){
		int res = Query(a, b, vec[i]);
		if(res == a) a = vec[i];
		if(res == b) b = vec[i];
	}
	//cout << "a = " << a << ", b = " << b << endl;
	mp[a] = mp[b] = vector<int>();
	mp[a].push_back(a);
	mp[b].push_back(b);
	for(int i = 0; i < vec.size(); i++){
		if(vec[i] == a || vec[i] == b) continue;
		int res = Query(a, b, vec[i]);
		if(!mp.count(res)) mp[res] = vector<int>();
		mp[res].push_back(vec[i]);
	}
	for(auto [x, v] : mp){
		//cout << "x = " << x << ", v = "; for(int y : v) cout << y << " "; cout << endl;
		solve(v);
		if(x != a && x != b) nv.push_back(x);
	}
	sort(nv.begin(), nv.end(), [&](int x, int y){
		return Query(a, x, y) == x;
	});
	//cout << "OK\n";
	//cout << "nv = " << nv.size() << ", vec: " << vec.size() << endl;
	if(nv.size()){
		for(int i = 0; i < nv.size() - 1; i++) addEdge(nv[i], nv[i + 1]);
		addEdge(a, nv[0]);
		addEdge(b, nv[nv.size() - 1]);
	} else addEdge(a, b);
}
 
void Solve(int N){
	vector<int> jizz = vector<int>();
	for(int i = 0; i < N; i++) jizz.push_back(i);
	solve(jizz);
}

Compilation message

meetings.cpp: In function 'void solve(std::vector<int>)':
meetings.cpp:24:2: error: 'map' was not declared in this scope
   24 |  map<int, vector<int>> mp;
      |  ^~~
meetings.cpp:5:1: note: 'std::map' is defined in header '<map>'; did you forget to '#include <map>'?
    4 | #include <algorithm>
  +++ |+#include <map>
    5 | #include <vector>
meetings.cpp:24:6: error: expected primary-expression before 'int'
   24 |  map<int, vector<int>> mp;
      |      ^~~
meetings.cpp:27:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for(int i = 2; i < vec.size(); i++){
      |                 ~~^~~~~~~~~~~~
meetings.cpp:33:2: error: 'mp' was not declared in this scope
   33 |  mp[a] = mp[b] = vector<int>();
      |  ^~
meetings.cpp:36:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for(int i = 0; i < vec.size(); i++){
      |                 ~~^~~~~~~~~~~~
meetings.cpp:53:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |   for(int i = 0; i < nv.size() - 1; i++) addEdge(nv[i], nv[i + 1]);
      |                  ~~^~~~~~~~~~~~~~~