QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#419770#8591. ShopsMuhammad_Aneeq#0 177ms103828kbC++141.1kb2024-05-24 11:05:142024-05-24 11:05:16

Judging History

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

  • [2024-05-24 11:05:16]
  • 评测
  • 测评结果:0
  • 用时:177ms
  • 内存:103828kb
  • [2024-05-24 11:05:14]
  • 提交

answer

/*
بسم الله الرحمن الرحيم
Author:
                          (:Muhammad Aneeq:)
*/

#include <iostream>
#include <vector>
using namespace std;
int const N=5e5+10;
vector<pair<int,int>>nei[N]={};
int ans[N]={};
int dif[N]={};
void dfs(int n)
{
	int mv=-1,dis=1e9+10;
	for (auto [i,w]:nei[n])
	{
		if (ans[i]!=ans[n])
		{
			if (mv==-1)
				mv=i,dis=w;
			if (dis>w)
			{
				mv=i;
				dis=w;
			}
		}
	}
	vector<int>f;
	for (auto [i,w]:nei[n])
	{
		if (ans[i]!=ans[n])
		{
			if (ans[i]==-1)
			{
				ans[i]=1-ans[n];
				f.push_back(i);
			}
		}
	}
	for (auto i:f)
		dfs(i);
}
inline void solve()
{
	int n,m;
	cin>>n>>m;
	while (m--)
	{
		int u,v,w;
		cin>>u>>v>>w;
		nei[u].push_back({v,w});
		nei[v].push_back({u,w});
	}
	for (int i=1;i<=n;i++)
		ans[i]=-1;
	ans[1]=1;
	dfs(1);
	int z=0;
	for (int i=1;i<=n;i++)
		z=max(z,dif[i]);
	cout<<z<<endl;
	for (int i=1;i<=n;i++)
		cout<<(ans[i]==1?'B':'D');
	cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
        solve();
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 19076kb

input:

3 3
1 2 3
2 3 1
1 3 2

output:

0
BDD

result:

wrong answer your claimed answer is 0, but the inconveniences of your plan is actually 3

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 124ms
memory: 103828kb

input:

500000 499999
1 2 776715136
2 3 406881694
3 4 265792290
4 5 507607272
5 6 182246639
6 7 997847597
7 8 164130256
8 9 278962226
9 10 411194641
10 11 363646402
11 12 672225656
12 13 494629089
13 14 717664153
14 15 121619271
15 16 476857704
16 17 301215244
17 18 810217743
18 19 850722975
19 20 10710274
...

output:

0
BDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBDBD...

result:

wrong answer your claimed answer is 0, but the inconveniences of your plan is actually 998789691

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #31:

score: 0
Wrong Answer
time: 177ms
memory: 42252kb

input:

366489 397001
2 127909 1
7 171229 1
8 158597 1
11 282213 1
14 356007 1
15 286102 1
16 93205 1
17 260111 1
18 138962 1
20 359938 1
29 223905 1
31 357684 1
32 259968 1
34 65205 1
37 200276 1
41 83195 1
43 159858 1
48 332277 1
50 320322 1
51 338467 1
53 262785 1
55 83815 1
56 173198 1
58 169473 1
63 19...

output:

0
BBBDDDDBBBBBDDDBBDDBBBBDBDDDDBBBBBBDDBBDDDDDBDBDBBBBBDDDBDBDDBBBDBDBBBDBBDDBBDDDBBDDBBBDBDDBBDBDBBDDDDBDDBDDDBBBBDDBBBBBDDDDDDDBBBBDBDDDDDDBDDBBDDBDBBBDDDDDBDBDBDBDDBDBDBDBDDDBDBDBBBDBDBBBDDBDBBBDBBBBDBBBBBDDDDBBDBDDBDBBDDBDDDDDBDDBBDBBDDDBDBDBBDDDDBBDBDBDDDBBDBBDBBBDBDBDDBBBDBDDDBDDDDBDDDDDDBBDDD...

result:

wrong answer your claimed answer is 0, but the inconveniences of your plan is actually 1

Subtask #5:

score: 0
Skipped

Dependency #1:

0%