QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#97568 | #3614. Math Trade | SDTBU_LY | WA | 1ms | 1744kb | C++14 | 1.1kb | 2023-04-17 09:47:28 | 2023-04-17 09:47:29 |
Judging History
answer
#include <stdio.h>
#include <string.h>
int main(){
char s[101][3][20];
char vis[101][3];
int i,j,k,a,flag;
int n,ans=0;
for(i=0;i<300;i++){
vis[0][i]=-1;
}
scanf("%d",&n);
for(i=0;i<n;i++){
for(j=0;j<3;j++){
scanf(" %s",s[i][j]);
}
}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(vis[j][1]!=-1){
continue;
}
if(strcmp(s[i][2],s[j][1])==0){
vis[i][2]=j;
vis[j][1]=i;
break;
}
}
}
for(i=0;i<n;i++){
if(vis[i][1]==-1||vis[i][2]==-1){
continue;
}
a=vis[i][2];
flag=0;
while(1){
if(a==i){
break;
}
if(vis[a][2]==-1){
flag=1;
break;
}
a=vis[a][2];
}
if(flag==0){
ans++;
}
}
if(ans==0){
puts("No trades possible");
}
else{
printf("%d\n",ans);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 1592kb
input:
4 Sally Clock Doll Steve Doll Painting Carlos Painting Clock Maria Candlestick Vase
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 1ms
memory: 1744kb
input:
4 Abby Bottlecap Card Bob Card Spoon Chris Spoon Chair Dan Pencil Pen
output:
No trades possible
result:
ok single line: 'No trades possible'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 1488kb
input:
10 P0 I0 I0X P1 I1 I2 P2 I2 I9 P3 I3 I7 P4 I4 I6 P5 I5 I3 P6 I6 I1 P7 I7 I8 P8 I8 I5 P9 I9 I4
output:
9
result:
wrong answer 1st lines differ - expected: '5', found: '9'