QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#313957#7977. 彩虹航线yyyyxh1 289ms45088kbC++142.0kb2024-01-25 10:45:532024-01-25 10:45:54

Judging History

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

  • [2024-01-25 10:45:54]
  • 评测
  • 测评结果:1
  • 用时:289ms
  • 内存:45088kb
  • [2024-01-25 10:45:53]
  • 提交

answer

#include <cstdio>
#include <vector>
#include <algorithm>
#define fi first
#define se second
using namespace std;
int read(){
	char c=getchar();int x=0;
	while(c<48||c>57) c=getchar();
	do x=(x<<1)+(x<<3)+(c^48),c=getchar();
	while(c>=48&&c<=57);
	return x;
}
const int T=1e6,INF=0x3f3f3f3f;
const int N=153,M=22503;
int n,m,k;
vector<int> vec[T+3],g[N];
int eu[M],ev[M],col[M];
int cl[N][N],cr[N][N];
bool del[N];
int mn[N],tmn[N],mat[N],res[N];
int main(){
	n=read();m=read();k=read();col[0]=INF;
	for(int i=1;i<=m;++i){
		int u=read(),v=read();
		eu[i]=u;ev[i]=v;
		for(int j=1;j<=k;++j) vec[read()].emplace_back(i);
		int x=find(cl[u]+1,cl[u]+n+1,0)-cl[u];
		int y=find(cr[v]+1,cr[v]+n+1,0)-cr[v];
		if(x!=y){
			bool op=x<y;
			int p=op?v:u,las=0;
			while(true){
				if(op){
					if(p){
						cr[p][y]=cr[p][x];
						cr[p][x]=las;
						las=p;p=cr[p][y];
					}
					else break;
				}
				else{
					if(p){
						cl[p][x]=cl[p][y];
						cl[p][y]=las;
						las=p;p=cl[p][x];
					}
					else break;
				}
				op^=1;
			}
		}
		cl[u][min(x,y)]=v;cr[v][min(x,y)]=u;
	}
	for(int i=1;i<=m;++i) col[i]=find(cl[eu[i]]+1,cl[eu[i]]+n+1,ev[i])-cl[eu[i]];
	for(int c=1;c<=T;++c){
		if(vec[c].empty()) continue;
		for(int i=1;i<=n;++i) g[i].clear();
		for(int x:vec[c]) if(!del[x]) g[eu[x]].emplace_back(x);
		for(int i=1;i<=n;++i){
			sort(g[i].begin(),g[i].end(),[](int a,int b){return col[a]<col[b];});
			mat[i]=tmn[i]=mn[i]=0;
		}
		bool fl=1;
		while(fl){
			fl=0;
			for(int u=1;u<=n;++u){
				if(mat[u]||g[u].empty()) continue;
				int x=g[u].back();
				g[u].pop_back();
				if(col[x]<col[tmn[ev[x]]]) tmn[ev[x]]=x;
			}
			for(int v=1;v<=n;++v){
				if(col[tmn[v]]<col[mn[v]]){
					if(mn[v]) mat[eu[mn[v]]]=0;
					mn[v]=tmn[v];fl=1;
					mat[eu[mn[v]]]=mn[v];
				}
				tmn[v]=0;
			}
		}
		for(int i=1;i<=n;++i) if(mat[i]) del[mat[i]]=1,res[mat[i]]=c;
	}
	for(int i=1;i<=m;++i) printf("%d ",res[i]);
	putchar('\n');
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 1
Accepted

Test #1:

score: 1
Accepted
time: 4ms
memory: 27460kb

input:

150 150 1
144 5 1
141 54 1
26 120 1
148 68 1
136 62 1
114 1 1
33 136 1
85 100 1
97 124 1
84 66 1
107 81 1
82 135 1
112 44 1
20 89 1
50 32 1
52 94 1
89 88 1
3 57 1
130 23 1
140 150 1
96 37 1
122 38 1
41 63 1
99 85 1
13 95 1
142 47 1
95 4 1
69 17 1
27 119 1
73 93 1
108 43 1
54 18 1
37 76 1
67 114 1
40...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 

result:

ok construction is correct.

Test #2:

score: 0
Accepted
time: 4ms
memory: 27364kb

input:

150 150 1
117 132 96
147 4 114
67 57 60
62 94 20
48 117 68
31 144 27
19 44 121
3 51 92
83 52 67
26 125 56
8 124 75
125 31 52
79 8 21
132 14 136
77 111 45
134 136 145
129 73 85
122 92 143
59 76 36
60 127 115
102 126 133
10 106 32
93 35 106
75 47 102
45 140 41
44 108 146
25 98 106
140 116 76
143 3 87
...

output:

96 114 60 20 68 27 121 92 67 56 75 52 21 136 45 145 85 143 36 115 133 32 106 102 41 146 106 76 87 90 116 15 147 51 35 85 15 83 43 105 89 12 89 140 103 114 135 78 93 80 87 93 19 7 125 132 96 96 99 48 1 63 3 6 146 116 48 9 126 6 106 64 74 84 16 23 119 51 7 83 96 56 94 97 27 15 51 106 95 32 70 103 75 8...

result:

ok construction is correct.

Test #3:

score: 0
Accepted
time: 3ms
memory: 27320kb

input:

150 10 1
35 145 1
145 88 2
130 14 1
111 142 1
138 99 1
76 73 1
101 79 1
147 137 2
65 64 1
108 8 2

output:

1 2 1 1 1 1 1 2 1 2 

result:

ok construction is correct.

Subtask #2:

score: 0
Wrong Answer

Test #4:

score: 0
Wrong Answer
time: 289ms
memory: 44156kb

input:

75 5625 150
11 6 680849 150419 731361 419631 223710 806977 837589 529911 568337 456216 515190 302854 672904 388629 548276 803173 770491 610684 550790 786097 253610 446581 705772 610053 637171 567249 365794 571846 431219 213414 466432 53255 748825 765338 761154 556712 159152 463622 706471 49434 59624...

output:

980 3381 1885 123 0 5914 7108 3518 0 7002 11604 5196 6995 12971 14216 631 7775 5611 9896 1481 11434 2253 2098 170 1112 7853 9236 0 0 10801 14123 1124 2145 201 8611 430 0 1838 14248 0 0 23465 22000 425 0 10530 14416 0 16645 6954 5793 1073 6631 8819 14 1400 11886 23715 16656 3635 2287 15866 21920 0 71...

result:

wrong answer Integer 0 violates the range [1, 843750]

Subtask #3:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 9ms
memory: 27372kb

input:

150 300 2
81 6 1 2
64 88 1 2
5 76 2 1
22 9 2 1
32 142 1 2
97 32 2 1
18 87 1 2
146 100 2 1
56 139 1 2
61 109 2 1
124 105 2 1
126 145 1 2
16 19 1 2
16 138 2 1
131 111 2 1
145 111 2 1
59 59 2 1
89 43 1 2
2 38 1 2
63 149 2 1
46 48 1 2
140 131 1 2
86 10 2 1
116 40 1 2
123 38 2 1
75 109 2 1
131 142 1 2
9 ...

output:

1 2 1 0 0 2 1 1 2 1 0 0 2 1 2 1 2 0 1 1 2 0 0 1 2 0 0 2 1 2 2 1 1 1 1 1 2 2 1 2 2 1 2 2 0 2 2 1 0 0 1 2 2 2 2 0 1 2 2 1 1 2 1 2 2 1 2 1 1 1 2 2 2 0 1 1 2 1 2 1 1 2 1 2 0 2 2 2 1 2 2 1 2 1 1 2 2 2 2 2 1 2 0 2 0 2 1 2 1 1 1 1 1 2 2 2 2 1 1 0 2 2 1 1 2 0 2 1 2 2 1 0 1 1 0 1 1 2 1 2 1 1 1 1 1 0 1 2 0 1 ...

result:

wrong answer Integer 0 violates the range [1, 600]

Subtask #4:

score: 0
Wrong Answer

Test #18:

score: 0
Wrong Answer
time: 82ms
memory: 45088kb

input:

149 22201 150
106 24 20 90 56 109 85 33 76 25 97 77 134 75 15 24 88 16 93 126 43 94 116 120 28 130 21 140 70 111 71 32 29 41 132 39 84 62 27 92 55 117 129 125 127 104 74 114 14 145 36 121 22 69 68 133 59 65 58 148 131 40 54 118 110 3 61 105 4 112 142 122 73 37 1 113 45 87 57 89 103 98 100 63 146 106...

output:

0 128 126 84 52 63 137 0 0 0 0 22 65 0 0 0 122 91 0 0 145 106 0 0 102 0 129 0 0 0 135 32 77 0 122 0 0 131 0 62 41 0 0 0 124 0 0 0 116 127 105 26 131 0 135 0 0 116 117 60 0 0 109 0 0 66 0 0 0 139 71 104 111 79 0 116 140 139 0 80 94 0 107 84 144 149 87 0 0 90 99 0 93 135 118 25 97 98 99 100 101 102 10...

result:

wrong answer Integer 0 violates the range [1, 3330150]

Subtask #5:

score: 0
Wrong Answer

Test #23:

score: 0
Wrong Answer
time: 94ms
memory: 44896kb

input:

150 22500 150
117 116 91 74 113 95 110 26 141 115 38 66 71 138 17 83 112 99 149 18 3 44 15 28 53 114 96 37 7 145 20 109 80 19 117 16 63 27 42 137 135 132 14 39 1 148 147 30 68 126 12 32 57 67 119 139 124 46 133 24 36 51 69 88 131 60 86 140 102 29 100 150 35 123 84 85 90 105 75 45 77 143 130 127 98 7...

output:

0 117 0 0 0 0 99 65 0 102 0 0 142 14 0 0 0 0 0 0 76 0 0 0 0 143 135 0 120 0 0 0 0 34 0 0 100 0 110 0 0 42 0 0 107 39 0 0 123 137 145 43 102 43 55 0 57 92 0 123 61 62 130 64 0 97 0 95 106 0 0 0 74 74 0 0 0 78 0 80 0 82 83 51 0 130 0 0 89 128 0 92 93 18 0 144 0 0 70 76 0 102 103 0 105 147 0 108 0 110 ...

result:

wrong answer Integer 0 violates the range [1, 3375000]

Subtask #6:

score: 0
Wrong Answer

Test #29:

score: 0
Wrong Answer
time: 7ms
memory: 27452kb

input:

150 450 3
57 22 2 1 3
142 57 1 3 2
138 113 3 1 2
13 77 2 3 1
43 112 1 2 3
82 99 2 1 3
66 65 3 1 2
3 31 2 1 3
24 146 3 2 1
127 18 2 3 1
125 37 1 2 3
13 137 1 2 3
105 127 1 3 2
54 20 1 2 3
48 15 3 1 2
23 71 2 3 1
30 28 1 2 3
125 146 1 3 2
68 120 2 1 3
38 92 2 1 3
101 100 1 3 2
81 28 1 3 2
70 7 1 2 3
1...

output:

1 2 3 3 0 0 1 2 2 2 2 1 3 2 0 3 3 1 3 3 1 1 3 1 2 0 0 0 2 3 3 2 2 3 1 2 1 3 1 2 1 0 3 3 3 0 0 3 2 2 3 1 3 1 3 3 3 3 1 0 1 3 0 3 0 3 1 2 2 1 3 3 1 3 0 0 3 2 0 2 3 0 1 2 1 2 2 3 1 2 1 1 0 3 1 2 1 1 1 2 2 0 2 2 1 3 2 2 3 3 3 2 3 1 0 3 0 3 0 3 1 1 1 2 1 2 1 1 3 2 1 2 0 2 2 0 2 2 3 3 1 1 2 1 1 2 3 2 2 2 ...

result:

wrong answer Integer 0 violates the range [1, 1350]