ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#198129 | #3457. 排序程序 | FinderHT | 100 | 2332ms | 1172kb | C++ | 699b | 2023-11-19 15:56:10 | 2023-11-19 16:14:40 |
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN=105;
int a[MAXN];
int u[505],v[505];
void solve(){
int n,m;
cin>>n>>m;;
for(int i=1;i<=n;i++)a[i]=i;
for(int i=1;i<=m;i++)cin>>u[i]>>v[i];
for(int i=1;i<=n;i++)a[i]=i;
for(int i=1;i<=114514;i++){
random_shuffle(a+1,a+n+1);
for(int j=1;j<=m;j++){
if(a[u[j]]>a[v[j]])swap(a[u[j]],a[v[j]]);
}
for(int j=1;j<=n-1;j++){
if(a[j]>a[j+1]){
cout<<"NO"<<'\n';
return;
}
}
}
cout<<"YES"<<'\n';
}
signed main(){
int T;
cin>>T;
while(T--)solve();
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 58ms
memory: 1168kb
input:
10 3 1 2 3 3 3 1 2 1 3 2 3 3 3 1 2 1 3 2 3 3 1 2 3 3 3 1 3 1 2 2 3 4 6 3 4 2 4 1 4 2 3 1 2 1 3 4 6 1...
output:
NO YES YES NO YES NO YES NO YES YES
result:
ok 10 lines
Test #2:
score: 10
Accepted
time: 41ms
memory: 1168kb
input:
10 3 1 2 3 3 3 1 2 1 3 2 3 3 3 1 2 1 3 2 3 3 3 1 2 1 3 2 3 3 2 1 3 2 3 4 6 1 2 1 4 2 3 3 4 1 3 2 4 4...
output:
NO YES YES YES NO NO YES YES NO NO
result:
ok 10 lines
Test #3:
score: 10
Accepted
time: 169ms
memory: 1172kb
input:
10 4 6 1 2 1 4 2 3 3 4 1 3 2 4 8 28 1 8 5 7 1 7 1 5 2 4 4 6 1 6 5 8 1 3 1 4 7 8 2 3 2 8 2 6 4 8 3 6 ...
output:
NO NO YES YES YES NO YES NO YES NO
result:
ok 10 lines
Test #4:
score: 10
Accepted
time: 68ms
memory: 1168kb
input:
10 4 6 1 2 1 4 2 3 3 4 1 3 2 4 8 28 2 4 2 6 4 8 1 5 1 6 1 7 2 3 4 5 2 8 5 6 1 3 2 5 3 8 3 4 6 8 1 8 ...
output:
NO NO NO NO NO YES NO NO YES NO
result:
ok 10 lines
Test #5:
score: 10
Accepted
time: 244ms
memory: 1172kb
input:
10 4 6 1 2 1 4 2 3 3 4 1 3 2 4 8 28 1 2 3 5 2 7 1 5 4 6 2 3 1 8 2 4 1 6 6 7 1 3 1 7 4 7 2 8 7 8 5 6 ...
output:
NO NO YES YES YES YES YES NO YES YES
result:
ok 10 lines
Test #6:
score: 10
Accepted
time: 411ms
memory: 1168kb
input:
10 4 6 1 2 1 4 2 3 3 4 1 3 2 4 10 43 1 4 1 5 1 6 1 7 1 8 1 9 1 10 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 3...
output:
NO NO YES YES NO YES YES NO YES NO
result:
ok 10 lines
Test #7:
score: 10
Accepted
time: 445ms
memory: 1172kb
input:
10 4 6 1 2 1 4 2 3 3 4 1 3 2 4 10 43 1 4 1 5 1 6 1 7 1 8 1 9 1 10 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 3...
output:
NO NO YES YES YES YES NO NO NO YES
result:
ok 10 lines
Test #8:
score: 10
Accepted
time: 190ms
memory: 1172kb
input:
10 4 6 1 2 1 4 2 3 3 4 1 3 2 4 10 45 1 2 1 4 1 3 1 5 6 9 6 7 1 6 8 9 7 10 7 9 5 7 1 7 5 8 2 7 2 8 2 ...
output:
NO NO NO NO NO NO NO NO YES NO
result:
ok 10 lines
Test #9:
score: 10
Accepted
time: 322ms
memory: 1172kb
input:
10 4 6 1 2 1 4 2 3 3 4 1 3 2 4 10 45 2 9 1 3 1 4 1 5 1 6 1 7 1 8 7 10 1 10 2 6 8 9 2 5 6 9 8 10 6 7 ...
output:
NO NO YES YES NO NO NO NO YES NO
result:
ok 10 lines
Test #10:
score: 10
Accepted
time: 384ms
memory: 1168kb
input:
10 4 6 1 2 1 4 2 3 3 4 1 3 2 4 10 45 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 2 3 2 4 2 5 2 6 2 7 2 8 2 ...
output:
NO YES YES NO NO NO NO YES YES NO
result:
ok 10 lines
Extra Test:
score: 0
Extra Test Passed