QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#97433#3614. Math TradeshushuWA 2ms3376kbC++141.0kb2023-04-16 19:34:082023-04-16 19:34:09

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:34:09]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 3376kb
  • [2023-04-16 19:34:08]
  • Submitted

answer

#include <iostream>

using namespace std;

struct Trade {
    string name;
    string have;
    string want;
};

int main() {
    int n;
    cin >> n;

    struct Trade a[100];
    int y=1,z,w=0;
    string x;


    for(int i=0;i<n;i++){
        cin >> a[i].name >> a[i].have >> a[i].want;
        if(i>0)
            if(a[i].have == a[i-1].want){
                y++;
                if(y==2){
                    x=a[i-1].have;
                    z=i-1;
                }

            }
            else{
                if(a[i-1].want == x){
                    break;
                }
                else{
                    z++;
                    x=a[z].have;
                    if(a[i-1].want==x){
                        continue;
                    }
                    else{
                        w=1;
                        break;
                    }

                }
            }

    }
    if(w==1)
        cout << "No trades possible";
    else
        cout << y;

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3344kb

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

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

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:

No trades possible

result:

wrong answer 1st lines differ - expected: '5', found: 'No trades possible'