QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#227718#7640. Colorful Cyclesucup-team1447#RE 1842ms5592kbC++141.7kb2023-10-27 21:57:332023-10-27 21:57:33

Judging History

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

  • [2024-07-04 22:58:32]
  • hack成功,自动添加数据
  • (/hack/728)
  • [2023-10-27 21:57:33]
  • 评测
  • 测评结果:RE
  • 用时:1842ms
  • 内存:5592kb
  • [2023-10-27 21:57:33]
  • 提交

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 ull unsigned long long
#define int long long
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 3000005
#define inf 0x3f3f3f3f

int n,m;

int F(int x,int y){
	if(!x||!y)return 0;
	int z=0;
	For(i,0,7)if(x>>i&1)
		For(j,0,7)if(y>>j&1)z|=(1<<(i|j));
	return z;
}

int e[505][505];
bool ok;

int f[1<<18][18];

void work()
{
	n=read(),m=read(); ok=0;
	For(i,0,n)For(j,0,n)e[i][j]=0;
	For(i,1,m){
		int u=read()-1,v=read()-1,w=read()-1;
		e[u][v]|=(1<<(1<<w));
		e[v][u]|=(1<<(1<<w));
	}
	Rep(i,n-1,2){
		For(j,0,(1<<i)-1)For(k,0,i)f[j][k]=0;
		f[0][i]=1;
		For(s,0,(1<<i)-1)
			For(u,0,i)
				if(f[s][u]){
					int tmp=F(f[s][u],e[u][i]);
					if(tmp>>7&1){
						ok=1;
				//		cout<<"fs "<<s<<" "<<u<<" "<<i<<"\n";
						break;
					}
					For(v,0,i-1)
						if(!(s>>v&1)){
							tmp=F(f[s][u],e[u][v]);
							f[s|(1<<v)][v]|=tmp;
						}
				}
	}
	if(ok)puts("Yes");
	else puts("No");
}

signed main()
{
////	freopen("data.in","r",stdin);//freopen("std.out","w",stdout);
	int T=read();
	while(T--)work();
	return 0;
}
/*
5 10 5
01234
0 1

01234

*/

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5464kb

input:

2
3 3
1 2 3
2 3 1
1 3 2
5 6
1 2 1
2 3 1
1 3 2
3 4 3
3 5 3
4 5 3

output:

Yes
No

result:

ok 2 token(s): yes count is 1, no count is 1

Test #2:

score: 0
Accepted
time: 426ms
memory: 5360kb

input:

100000
7 10
7 2 2
6 4 2
6 1 2
7 1 3
3 4 1
6 7 1
2 6 3
3 1 2
5 3 1
2 1 1
7 10
5 7 3
7 1 1
4 6 3
6 3 1
3 4 3
4 2 2
3 2 3
1 3 3
3 7 1
1 4 2
7 10
5 6 3
3 5 2
7 2 3
7 3 3
1 2 2
4 3 2
7 4 2
6 1 2
2 6 1
7 5 2
7 10
7 1 3
7 5 3
6 4 1
7 6 1
1 4 1
3 4 2
2 7 2
1 3 1
3 5 3
5 1 3
7 10
6 7 2
3 4 3
1 4 2
5 3 2
7 4 ...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
...

result:

ok 100000 token(s): yes count is 92314, no count is 7686

Test #3:

score: 0
Accepted
time: 1035ms
memory: 3488kb

input:

50000
10 15
6 2 1
4 7 1
10 3 1
10 9 2
4 5 1
3 4 1
4 6 2
5 3 1
4 9 1
3 9 3
1 2 1
9 2 3
8 10 2
8 6 1
6 1 1
10 15
4 9 3
7 10 2
1 2 1
10 4 2
4 7 2
6 5 2
6 1 1
9 10 1
6 3 3
7 8 3
9 1 1
7 9 3
1 7 3
4 8 1
8 6 3
10 15
4 1 2
4 2 1
6 7 3
6 2 2
10 8 2
1 9 1
2 8 1
5 10 3
9 6 2
9 10 1
8 4 1
2 7 3
6 8 1
1 3 1
4 6...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Ye...

result:

ok 50000 token(s): yes count is 49364, no count is 636

Test #4:

score: 0
Accepted
time: 1842ms
memory: 5592kb

input:

50000
10 20
1 9 2
2 6 3
4 3 2
3 10 1
5 10 2
10 6 2
6 7 2
7 4 1
10 1 1
4 10 1
3 9 2
2 9 2
1 3 1
3 2 1
3 6 3
5 3 2
3 8 2
5 1 3
5 2 2
9 6 1
10 20
5 10 3
5 4 2
6 4 2
4 3 2
1 7 2
1 2 2
10 6 3
7 4 2
1 4 3
8 10 3
10 2 1
7 2 1
1 6 3
9 4 2
8 1 1
10 9 2
8 6 1
5 9 3
9 8 3
1 10 2
10 20
9 5 1
9 8 3
10 2 2
6 2 3
...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 50000 token(s): yes count is 49941, no count is 59

Test #5:

score: -100
Runtime Error

input:

1000
200 1000
42 68 2
101 170 2
79 159 2
65 106 3
82 28 2
92 196 3
28 37 1
5 103 1
93 183 1
117 119 3
48 127 3
139 70 2
68 100 2
95 104 1
123 134 1
65 142 2
54 69 3
45 63 1
38 60 3
142 130 2
117 36 3
43 89 2
41 143 2
49 47 1
91 130 2
151 7 1
194 149 1
24 85 2
157 41 2
177 132 2
145 40 3
124 138 2
11...

output:


result: