QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#93888#63. MeetingsHe_Ren0 43ms4008kbC++141.7kb2023-04-03 16:06:102023-04-03 16:06:12

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-03 16:06:12]
  • 评测
  • 测评结果:0
  • 用时:43ms
  • 内存:4008kb
  • [2023-04-03 16:06:10]
  • 提交

answer

#include<bits/stdc++.h>
#include"meetings.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 2e3 + 5;

int ask(int u,int v,int w)
{
	return Query(u-1, v-1, w-1) + 1;
}
void answer(int u,int v)
{
	if(u > v) swap(u, v);
	Bridge(u-1, v-1);
}

vector<int> g[MAXN];

void add_edge(int u,int v)
{
	g[u].emplace_back(v);
	g[v].emplace_back(u);
}
void del_edge(int u,int v)
{
	g[u].erase(find(g[u].begin(), g[u].end(), v));
	g[v].erase(find(g[v].begin(), g[v].end(), u));
}

bool del[MAXN];
int siz[MAXN], mxson[MAXN];
void dfs_siz(int u,int fa)
{
	siz[u] = 1; mxson[u] = 0;
	for(int v: g[u]) if(v != fa && !del[v])
	{
		dfs_siz(v,u);
		siz[u] += siz[v];
		mxson[u] = max(mxson[u], siz[v]);
	}
}

int rt, totsiz;
void dfs_rt(int u,int fa)
{
	mxson[u] = max(mxson[u], totsiz - siz[u]);
	if(mxson[u] < mxson[rt]) rt = u;
	for(int v: g[u]) if(v != fa && !del[v])
		dfs_rt(v,u);
}

void divid(int u,int k)
{
	dfs_siz(u,0);
	rt = u; totsiz = siz[u];
	dfs_rt(u,0);
	u = rt; del[u] = 1;
	
	vector<int> ch;
	for(int v: g[u]) if(!del[v])
		ch.emplace_back(v);
	sort(ch.begin(), ch.end(), [&] (int x,int y){
		return siz[x] > siz[y];
	});
	
	for(int v: ch)
	{
		int w = ask(u, v, k);
		if(w == u) continue;
		if(w == v)
		{
			divid(v, k);
			return;
		}
		
		del_edge(u,v);
		add_edge(u, w);
		add_edge(v, w);
		if(w != k) add_edge(w, k);
		return;
	}
	
	add_edge(u, k);
}

void Solve(int n)
{
	mt19937 gen(114514);
	vector<int> id(n);
	iota(id.begin(), id.end(), 1);
	shuffle(id.begin(), id.end(), gen);
	
	for(int u: id) if(u != id[1])
	{
		divid(id[1], u);
	}
	
	for(int u=1; u<=n; ++u)
		for(int v: g[u]) if(u < v)
			answer(u, v);
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 7
Accepted
time: 2ms
memory: 3712kb

input:

3
0 2
0 1

output:

Accepted: 1

result:

ok 1 move(s)

Test #2:

score: -7
Wrong Answer
time: 0ms
memory: 3756kb

input:

4
1 2
0 2
0 3

output:

Wrong Answer [4]

result:

wrong answer 

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #40:

score: 0
Wrong Answer
time: 43ms
memory: 4008kb

input:

2000
58 503
623 1403
1004 1083
249 491
1524 1849
192 562
1261 1877
547 909
267 896
747 1986
381 1329
57 317
779 886
469 1652
628 1456
1732 1790
700 825
494 1799
1450 1733
103 1069
1114 1342
243 1496
930 1361
240 905
398 1737
1008 1765
357 954
1157 1898
1228 1344
1062 1731
160 1977
40 364
343 694
108...

output:

Wrong Answer [4]

result:

wrong answer