QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#503473#4632. Card Sharktarjen#WA 1ms3600kbC++201.5kb2024-08-03 19:10:402024-08-03 19:10:40

Judging History

你现在查看的是最新测评结果

  • [2024-08-03 19:10:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3600kb
  • [2024-08-03 19:10:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
vector<pair<int,int>> ve[maxn];
vector<int> st;
void dfs(int u,int id)//欧拉回路
{
    while(!ve[u].empty()){
        auto [to,idd]=ve[u].back();ve[u].pop_back();
        dfs(to,idd);
    }
    if(id!=-1)st.push_back(id);
}
void no(){
    cout<<-1;exit(0);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,b;cin>>n>>m>>b;
    b--;
    vector<int> in(m),out(m);
    for(int i=1;i<=n;i++){
        string s;cin>>s;
        int pr=-1;
        for(int j=0;j<(int)s.size();j++){
            if(s[j]=='1'){
                if(pr==-1){
                    if(j>=m)no();
                    pr=j;
                }
                else{
                    if((j-pr)%m!=0)no();
                    pr=j;
                }
            }
        }
        int res=(int)s.size()-1-pr;
        if(res>=m)no();
        res=m-1-res;
        ve[pr%m].emplace_back(res,i);
        in[res]++;
        out[pr%m]++;
    }
    dfs(b,-1);
    if((int)st.size()!=n)no();
    if(in[b]==out[b]){
        for(int i=0;i<m;i++)if(in[b]!=out[b])no();
    }
    else{
        if(in[b]!=out[b]-1)no();
        int cnt=0;
        for(int i=0;i<m;i++)if(i!=b){
            if(in[i]==out[i])continue;
            if(in[i]==out[i]+1)cnt++;
            else no();
        }
        if(cnt!=1)no();
    }
    for(auto it:st)cout<<it<<" ";;cout<<"\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3600kb

input:

5 4 3
0100010
00100
001000100
0010
0100010

output:

1 2 5 3 4 

result:

wrong answer 1st lines differ - expected: '2 1 3 5 4', found: '1 2 5 3 4 '