QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#198310#3614. Math TradeZhou_JKWA 1ms3440kbC++231.1kb2023-10-03 12:42:122023-10-03 12:42:12

Judging History

This is the latest submission verdict.

  • [2023-10-03 12:42:12]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3440kb
  • [2023-10-03 12:42:12]
  • Submitted

answer

#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
using namespace std;
const int N=105;
int n;
int tot;
map<string,int>id;
vector<int>G[N*2];
int deg[N*2];
bool vis[N*2];
int cnt;
bool flag;
void dfs(int u)
{
    vis[u]=true;
    cnt++;
    for(int v:G[u])
    {
        if(deg[v]!=1)
        {
            flag=false;
            return;
        }
        if(vis[v]) continue;
        dfs(v);
    }
    return;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        string name,s,t;
        cin>>name>>s>>t;
        if(!id.count(s)) id[s]=++tot;
        if(!id.count(t)) id[t]=++tot;
        G[id[s]].emplace_back(id[t]);
        G[id[t]].emplace_back(id[s]);
        deg[id[t]]++;
    }
    int ans=0;
    for(int i=1;i<=tot;i++)
        if(!vis[i])
        {
            flag=true;
            cnt=0;
            dfs(i);
            if(flag) ans=max(ans,cnt);
        }
    if(ans==0) cout<<"No trades possible";
    else cout<<ans;
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3420kb

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

input:

4
Abby Bottlecap Card
Bob Card Spoon
Chris Spoon Chair
Dan Pencil Pen

output:

2

result:

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