QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#507905#7157. Bikes vs CarsCrysfly0 5ms8604kbC++171.9kb2024-08-06 23:16:322024-08-06 23:16:32

Judging History

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

  • [2024-08-06 23:16:32]
  • 评测
  • 测评结果:0
  • 用时:5ms
  • 内存:8604kb
  • [2024-08-06 23:16:32]
  • 提交

answer

// what is matter? never mind. 
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define int long long
#define ull unsigned long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 500006
#define inf 0x3f3f3f3f

int n,up;
int a[505][505],b[505][505];

struct edge{
	int u,v,w;
};

int fa[maxn];
int gf(int x){
	while(x!=fa[x])x=fa[x]=fa[fa[x]];
	return x;
}

vector<edge> mst(vector<edge>es){
	For(i,1,n) fa[i]=i;
	sort(es.begin(),es.end(),[&](auto a,auto b){
		return a.w>b.w;
	});
	vector<edge>res;
	for(auto [u,v,w]:es){
		if(gf(u)!=gf(v)){
			fa[gf(u)]=gf(v);
			res.pb({u,v,w});
		}
	}
	return res;
}

signed main()
{
	n=read(),up=read();
	For(i,1,n)For(j,1,i-1)a[i][j]=a[j][i]=read();
	For(i,1,n)For(j,1,i-1)b[i][j]=b[j][i]=read();
	For(i,1,n)For(j,i+1,n)
		For(k,1,n)if(k!=i&&k!=j){
			if(min(a[i][k],a[k][j])>a[i][j]){
				puts("NO");
				exit(0);
			}
			if(min(b[i][k],b[k][j])>b[i][j]){
				puts("NO");
				exit(0);
			}
		}
	
	vector<edge>es,resa,resb;
	For(i,1,n)For(j,i+1,n)es.pb({i,j,a[i][j]});
	resa=mst(es);
	es.clear();
	For(i,1,n)For(j,i+1,n)es.pb({i,j,b[i][j]});
	resb=mst(es);
	cout<<resa.size()+resb.size()<<"\n";
	for(auto [u,v,w]:resa) cout<<u-1<<" "<<v-1<<" "<<up-w<<"\n";
	for(auto [u,v,w]:resb) cout<<u-1<<" "<<v-1<<" "<<w<<"\n";
	return 0;
}
/*

*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 0ms
memory: 7684kb

input:

14 1000000
494185
494185 494185
494185 494185 494185
494185 494185 494185 494185
494185 494185 494185 494185 494185
494185 494185 494185 494185 494185 494185
494185 494185 494185 494185 494185 494185 494185
494185 494185 494185 494185 494185 494185 494185 494185
494185 494185 494185 494185 494185 49...

output:

26
5 7 505815
6 11 505815
6 10 505815
6 9 505815
6 8 505815
6 7 505815
5 13 505815
5 12 505815
4 13 505815
3 13 505815
0 12 505815
1 11 505815
1 2 505815
5 7 536641
6 11 536641
6 10 536641
6 9 536641
6 8 536641
6 7 536641
5 13 536641
5 12 536641
4 13 536641
3 13 536641
0 12 536641
1 11 536641
1 2 53...

result:

ok 

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 7656kb

input:

37 1000000
891050
891050 891050
891050 891050 891050
891050 891050 891050 891050
891050 891050 891050 891050 891050
891050 891050 891050 891050 891050 891050
891050 891050 891050 891050 891050 891050 891050
891050 891050 891050 891050 891050 891050 891050 891050
891050 891050 891050 891050 891050 89...

output:

72
15 29 108950
15 19 108950
15 20 108950
15 21 108950
15 22 108950
15 23 108950
15 24 108950
15 25 108950
15 26 108950
15 27 108950
15 28 108950
15 18 108950
15 30 108950
15 31 108950
15 32 108950
15 33 108950
15 34 108950
15 35 108950
15 36 108950
16 17 108950
16 18 108950
14 29 108950
11 36 10895...

result:

wrong answer Min Max 1 - 0 not equal aij, is 91852, should be 108950

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #16:

score: 17
Accepted
time: 1ms
memory: 7900kb

input:

14 1000000
494185
494185 494185
494185 494185 494185
494185 494185 494185 494185
494185 494185 494185 494185 494185
494185 494185 494185 494185 494185 494185
494185 494185 494185 494185 494185 494185 494185
494185 494185 494185 494185 494185 494185 494185 494185
494185 494185 494185 494185 494185 49...

output:

26
5 7 505815
6 11 505815
6 10 505815
6 9 505815
6 8 505815
6 7 505815
5 13 505815
5 12 505815
4 13 505815
3 13 505815
0 12 505815
1 11 505815
1 2 505815
5 7 536641
6 11 536641
6 10 536641
6 9 536641
6 8 536641
6 7 536641
5 13 536641
5 12 536641
4 13 536641
3 13 536641
0 12 536641
1 11 536641
1 2 53...

result:

ok 

Test #17:

score: 0
Wrong Answer
time: 1ms
memory: 7584kb

input:

37 1000000
891050
891050 891050
891050 891050 891050
891050 891050 891050 891050
891050 891050 891050 891050 891050
891050 891050 891050 891050 891050 891050
891050 891050 891050 891050 891050 891050 891050
891050 891050 891050 891050 891050 891050 891050 891050
891050 891050 891050 891050 891050 89...

output:

72
15 29 108950
15 19 108950
15 20 108950
15 21 108950
15 22 108950
15 23 108950
15 24 108950
15 25 108950
15 26 108950
15 27 108950
15 28 108950
15 18 108950
15 30 108950
15 31 108950
15 32 108950
15 33 108950
15 34 108950
15 35 108950
15 36 108950
16 17 108950
16 18 108950
14 29 108950
11 36 10895...

result:

wrong answer Min Max 1 - 0 not equal aij, is 91852, should be 108950

Subtask #4:

score: 0
Wrong Answer

Test #39:

score: 0
Wrong Answer
time: 5ms
memory: 8604kb

input:

163 1
0
0 0
0 1 0
1 0 0 0
0 0 0 0 0
1 0 0 0 1 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0 1
0 0 1 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 1
0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0 1
0 1 0 1 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 1 1 0 0 0
0 0 0 0 0 1 0 0 0 0 0 1 1 0 0
0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 1 1 0 0 ...

output:

324
11 66 0
62 141 0
22 60 0
11 56 0
42 61 0
42 58 0
42 57 0
11 62 0
42 55 0
11 65 0
107 156 0
107 145 0
107 144 0
72 130 0
11 70 0
107 142 0
42 53 0
11 74 0
42 51 0
87 117 0
87 104 0
62 125 0
62 127 0
22 71 0
11 33 0
11 34 0
108 116 0
62 129 0
62 131 0
87 103 0
42 49 0
11 41 0
87 105 0
11 43 0
11 4...

result:

wrong answer Min Max 1 - 0 not equal aij, is 0, should be 1

Subtask #5:

score: 0
Skipped

Dependency #2:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%