답안 #135693

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
135693 2019-07-24T09:49:53 Z dndhk Meetings (JOI19_meetings) C++14
0 / 100
121 ms 596 KB
#include "meetings.h"
#include <bits/stdc++.h>

#define pb push_back
#define all(v) ((v).begin(), (v).end())
#define sortv(v) sort(all(v))
#define sz(v) ((int)(v).size())
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define umax(a, b) (a)=max((a), (b))
#define umin(a, b) (a)=min((a), (b))
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define rep(i,n) FOR(i,1,n)
#define rep0(i,n) FOR(i,0,(int)(n)-1)
#define FI first
#define SE second
#define INF 2000000000
#define INFLL 1000000000000000000LL


using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX_N = 2000;

int N;
vector<int> vt[MAX_N+1];
vector<int> v;

vector<int> arr;
vector<int> tmp;

int now;

bool sf(int a, int b){
	int k = Query(now, a, b);
	return (k==a);
}

void calc(){
	while(!v.empty()){
		now = v.back(); v.pop_back();
		//cout<<now;
		if(vt[now].size()==0)	continue;
		int r = vt[now][rand()%vt[now].size()];	
		//cout<<" "<<r<<endl;
		tmp = vt[now]; 
		while(!vt[now].empty())	vt[now].pop_back();
		for(int i=0; i<tmp.size(); i++){
			int j = tmp[i];
			if(j==r){
				continue;
			}
			//cout<<now<<" "<<r<<" "<<j<<endl;
			int k = Query(now, r, j);
			if(k==j){
				arr.pb(j);
			}else{
				vt[k].pb(j);
			}
		}
		if(arr.empty()){
			Bridge(now, r);
			v.pb(now); v.pb(r); continue;
		}
		sort(arr.begin(), arr.end());
		v.pb(now); v.pb(r);
		Bridge(now, arr[0]); Bridge(arr.back(), r);
		int prv = arr.back(); arr.pop_back(); v.pb(prv);
		while(!arr.empty()){
			Bridge(arr.back(), prv); prv = arr.back(); arr.pop_back();
			v.pb(prv);
		}
	}
}

void Solve(int n) {
	srand(time(NULL));
	N = n;
	for(int i=1; i<N; i++){
		vt[0].pb(i);
	}
	v.pb(0);
	calc();
}

Compilation message

meetings.cpp: In function 'void calc()':
meetings.cpp:50:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<tmp.size(); i++){
                ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Incorrect 2 ms 380 KB Wrong Answer [3]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Incorrect 2 ms 380 KB Wrong Answer [3]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Incorrect 2 ms 380 KB Wrong Answer [3]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 121 ms 596 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -