QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#97427#3614. Math TradeSDTBU_LYWA 1ms1760kbC++141.1kb2023-04-16 19:23:042023-04-16 19:23:04

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-16 19:23:04]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 1760kb
  • [2023-04-16 19:23:04]
  • Submitted

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: 1ms
memory: 1760kb

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: 1488kb

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: 1ms
memory: 1584kb

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'