답안 #236530

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
236530 2020-06-02T12:47:00 Z Knps4422 Meetings (JOI19_meetings) C++14
100 / 100
1957 ms 900 KB
//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
*/
#include "meetings.h"
#define fr first
#define sc second
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define forn(x,y) for(int x = 1 ; x <= (int)y ; ++x)
#define all(x) (x).begin(),(x).end()
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
 
using namespace std;
 
typedef long long ll;
typedef unsigned int uint;
typedef complex<int> point;
const int nmax = 100005;
const ll linf = 1e18;
const ll mod = 998244353;
const int inf = INT_MAX;

vec < pii > eds;
int find_center(vec <int> &asd){
	if(asd.size() <= 2)return asd[0];
	vec<int> cnt(asd.size());
	int tries = asd.size()/10;
	while(tries --){
		int m = asd.size();
		int a, b, c;
		a = asd[rand()%m];
		b = asd[rand()%m];
		while(b == a) b = asd[rand()%m];
		c = asd[rand()%m];
		while(c == b || c == a)c = asd[rand()%m];
		// a,b,c - random din asd
		int p = Query(a,b,c);
		cnt[ lower_bound(all(asd),p) - asd.begin()]++;
	}
	int mx = 0;
	for(int i = 0; i < cnt.size() ; i++){
		if(cnt[mx] < cnt[i])mx = i;
	}
	cnt.clear();
	return asd[mx];
}

void solves(vec <int> &tb){
	if(tb.size() == 1)return ;
	int A = find_center(tb);
	int B = tb[0];
	if(B == A)B = tb[1];
	for(int i : tb){
		if(i != A && i != B && Query(A,B,i) == i) B = i;
	}
	eds.pb({A,B});
	vec < int > left;
	vec < int > right;
	for(int  i : tb){
		if(i != A && i != B){
			if(Query(A,B,i) == A){
				left.pb(i);
			}else{
				right.pb(i);
			}
		}
	}
	left.pb(A);
	sort(all(left));	
	solves(left);
	left.clear();
	right.pb(B);
	sort(all(right));
	solves(right);
	right.clear();
}


void Solve(int n){
	vec < int > asd;
	for(int i= 0; i <n ; i++)asd.pb(i);
	solves(asd);
	for(pii ed : eds){
		Bridge(min(ed.fr,ed.sc),max(ed.fr,ed.sc));
	}
	asd.clear();
}

/*
int main(){
	fast;
	
}
*/

Compilation message

meetings.cpp: In function 'int find_center(std::vector<int>&)':
meetings.cpp:50:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < cnt.size() ; i++){
                 ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 416 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 416 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 23 ms 384 KB Output is correct
28 Correct 23 ms 512 KB Output is correct
29 Correct 21 ms 384 KB Output is correct
30 Correct 19 ms 384 KB Output is correct
31 Correct 18 ms 384 KB Output is correct
32 Correct 26 ms 384 KB Output is correct
33 Correct 34 ms 384 KB Output is correct
34 Correct 40 ms 384 KB Output is correct
35 Correct 37 ms 384 KB Output is correct
36 Correct 21 ms 384 KB Output is correct
37 Correct 18 ms 384 KB Output is correct
38 Correct 21 ms 384 KB Output is correct
39 Correct 22 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1509 ms 740 KB Output is correct
2 Correct 1803 ms 896 KB Output is correct
3 Correct 1739 ms 888 KB Output is correct
4 Correct 1827 ms 640 KB Output is correct
5 Correct 1425 ms 632 KB Output is correct
6 Correct 1205 ms 760 KB Output is correct
7 Correct 1568 ms 648 KB Output is correct
8 Correct 1713 ms 760 KB Output is correct
9 Correct 1715 ms 888 KB Output is correct
10 Correct 1532 ms 760 KB Output is correct
11 Correct 1759 ms 888 KB Output is correct
12 Correct 1403 ms 888 KB Output is correct
13 Correct 1291 ms 760 KB Output is correct
14 Correct 1537 ms 632 KB Output is correct
15 Correct 1350 ms 636 KB Output is correct
16 Correct 1417 ms 888 KB Output is correct
17 Correct 1659 ms 900 KB Output is correct
18 Correct 1440 ms 780 KB Output is correct
19 Correct 1414 ms 760 KB Output is correct
20 Correct 1766 ms 648 KB Output is correct
21 Correct 1763 ms 644 KB Output is correct
22 Correct 1776 ms 888 KB Output is correct
23 Correct 1666 ms 736 KB Output is correct
24 Correct 1783 ms 660 KB Output is correct
25 Correct 1782 ms 608 KB Output is correct
26 Correct 1761 ms 788 KB Output is correct
27 Correct 1768 ms 864 KB Output is correct
28 Correct 1957 ms 892 KB Output is correct
29 Correct 1508 ms 888 KB Output is correct
30 Correct 1515 ms 888 KB Output is correct
31 Correct 1819 ms 764 KB Output is correct
32 Correct 1361 ms 844 KB Output is correct
33 Correct 1284 ms 888 KB Output is correct
34 Correct 20 ms 384 KB Output is correct
35 Correct 20 ms 384 KB Output is correct
36 Correct 22 ms 384 KB Output is correct
37 Correct 18 ms 384 KB Output is correct
38 Correct 18 ms 384 KB Output is correct
39 Correct 27 ms 384 KB Output is correct
40 Correct 35 ms 384 KB Output is correct
41 Correct 42 ms 384 KB Output is correct
42 Correct 36 ms 384 KB Output is correct
43 Correct 20 ms 456 KB Output is correct
44 Correct 19 ms 384 KB Output is correct
45 Correct 21 ms 384 KB Output is correct
46 Correct 22 ms 384 KB Output is correct
47 Correct 6 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 5 ms 384 KB Output is correct
51 Correct 5 ms 384 KB Output is correct
52 Correct 5 ms 384 KB Output is correct
53 Correct 6 ms 384 KB Output is correct
54 Correct 5 ms 384 KB Output is correct
55 Correct 5 ms 384 KB Output is correct
56 Correct 5 ms 384 KB Output is correct
57 Correct 5 ms 384 KB Output is correct
58 Correct 5 ms 384 KB Output is correct
59 Correct 5 ms 384 KB Output is correct
60 Correct 5 ms 384 KB Output is correct
61 Correct 4 ms 384 KB Output is correct
62 Correct 5 ms 384 KB Output is correct
63 Correct 4 ms 384 KB Output is correct
64 Correct 4 ms 384 KB Output is correct
65 Correct 4 ms 384 KB Output is correct
66 Correct 5 ms 384 KB Output is correct
67 Correct 4 ms 384 KB Output is correct
68 Correct 5 ms 384 KB Output is correct
69 Correct 5 ms 384 KB Output is correct
70 Correct 4 ms 384 KB Output is correct
71 Correct 4 ms 384 KB Output is correct
72 Correct 4 ms 384 KB Output is correct