QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#97432 | #3614. Math Trade | shushu | WA | 1ms | 3388kb | C++14 | 1.0kb | 2023-04-16 19:31:55 | 2023-04-16 19:31:59 |
Judging History
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 << z << "No trades possible";
else
cout << y;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3380kb
input:
4 Sally Clock Doll Steve Doll Painting Carlos Painting Clock Maria Candlestick Vase
output:
3
result:
ok single line: '3'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3388kb
input:
4 Abby Bottlecap Card Bob Card Spoon Chris Spoon Chair Dan Pencil Pen
output:
1No trades possible
result:
wrong answer 1st lines differ - expected: 'No trades possible', found: '1No trades possible'