답안 #375449

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
375449 2021-03-09T12:14:20 Z Seanliu Meetings (JOI19_meetings) C++17
29 / 100
2000 ms 1908 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;
	unordered_map<int, vector<int>> mp;
	vector<int> nv = vector<int>();
	mp[vec[1]] = mp[vec[0]] = vector<int>();
	mp[vec[0]].push_back(vec[0]);
	mp[vec[1]].push_back(vec[1]);
	for(int i = 2; i < vec.size(); i++){
		int res = Query(vec[0], vec[1], 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 != vec[0] && x != vec[1]) nv.push_back(x);
	}
	sort(nv.begin(), nv.end(), [&](int a, int b){
		return Query(vec[0], a, b) == a;
	});
	//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(vec[0], nv[0]);
		addEdge(vec[1], nv[nv.size() - 1]);
	} else addEdge(vec[0], vec[1]);
}
 
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:29:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for(int i = 2; i < vec.size(); i++){
      |                 ~~^~~~~~~~~~~~
meetings.cpp:45:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for(int i = 0; i < nv.size() - 1; i++) addEdge(nv[i], nv[i + 1]);
      |                  ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 1 ms 492 KB Output is correct
23 Correct 1 ms 492 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 1 ms 492 KB Output is correct
23 Correct 1 ms 492 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
27 Correct 5 ms 492 KB Output is correct
28 Correct 6 ms 492 KB Output is correct
29 Correct 7 ms 492 KB Output is correct
30 Correct 5 ms 492 KB Output is correct
31 Correct 4 ms 492 KB Output is correct
32 Correct 6 ms 492 KB Output is correct
33 Correct 10 ms 492 KB Output is correct
34 Correct 14 ms 492 KB Output is correct
35 Correct 12 ms 512 KB Output is correct
36 Correct 6 ms 504 KB Output is correct
37 Correct 9 ms 492 KB Output is correct
38 Correct 12 ms 492 KB Output is correct
39 Correct 179 ms 1132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 443 ms 884 KB Output is correct
2 Correct 474 ms 748 KB Output is correct
3 Correct 486 ms 844 KB Output is correct
4 Correct 445 ms 876 KB Output is correct
5 Correct 365 ms 748 KB Output is correct
6 Correct 409 ms 748 KB Output is correct
7 Correct 506 ms 748 KB Output is correct
8 Correct 573 ms 876 KB Output is correct
9 Correct 575 ms 1004 KB Output is correct
10 Correct 561 ms 1004 KB Output is correct
11 Correct 648 ms 748 KB Output is correct
12 Correct 342 ms 876 KB Output is correct
13 Correct 290 ms 876 KB Output is correct
14 Correct 547 ms 748 KB Output is correct
15 Correct 379 ms 1004 KB Output is correct
16 Correct 426 ms 876 KB Output is correct
17 Correct 924 ms 1132 KB Output is correct
18 Execution timed out 2540 ms 1908 KB Time limit exceeded
19 Halted 0 ms 0 KB -