QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#139021#4632. Card SharkSommohitoWA 6ms22316kbC++202.1kb2023-08-12 16:31:522023-08-12 16:31:59

Judging History

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

  • [2023-08-12 16:31:59]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:22316kb
  • [2023-08-12 16:31:52]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#ifdef APURBA
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
#define ALL(x) x.begin(),x.end()

const int N=2e5+5;

int n,m,b;
vector<pair<int,int>>v;

set<int>in[N];
set<int>out[N];
void no()
{
    cout<<-1;
    exit(0);
}

void TEST_CASES()
{
    cin>>n>>m>>b;
    b--;

    for(int i=0; i<n; i++)
    {
        string s;
        cin>>s;
        int shuru=-1;
        for(int j=0; j<s.size(); j++)
        {
            if(s[j]=='0') continue;

            if(shuru==-1)
            {
                int cur=(b-j+m)%m;

                int yy=(cur+s.size())%m;

                in[cur].insert(i);
                out[yy].insert(i);

                v.push_back({cur,yy});

                shuru=j;
            }
            else
            {
                if((j-shuru)%m!=0)
                {
                    cout<<-1;
                    exit(0);
                }
            }
        }
    }
    debug(v);
    int cur=0;
    vector<int>ans;
    while(ans.size()!=n)
    {
        debug(cur,ans);
        if(in[cur].size()==0)
        {
            no();
        }
        bool f=0;
        for(int w:in[cur])
        {

//            assert(in[cur].size()==out[cur].size()+1);
            if(in[cur].size()==2)
            {
                int sum=*in[cur].begin()+*in[cur].rbegin()-w;
                if(sum-w==*out[cur].begin())
                continue;
            }
            ans.push_back(w);
            in[cur].erase(w);
            cur=v[w].second;
            out[cur].erase(w);

            f=1;

            break;
        }
        if(!f) no();
    }
//    cout<<"Yes\n";
    for(int u:ans) cout<<u+1<<' ';
}


/*
*/

int32_t main()
{
#ifndef APURBA
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    //freopen("input.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        TEST_CASES();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 22204kb

input:

5 4 3
0100010
00100
001000100
0010
0100010

output:

2 1 3 5 4 

result:

ok single line: '2 1 3 5 4 '

Test #2:

score: 0
Accepted
time: 1ms
memory: 22244kb

input:

4 2 1
010
10101
010
10101

output:

2 1 4 3 

result:

ok single line: '2 1 4 3 '

Test #3:

score: 0
Accepted
time: 1ms
memory: 22208kb

input:

1 5 3
001000010000100

output:

1 

result:

ok single line: '1 '

Test #4:

score: 0
Accepted
time: 0ms
memory: 22316kb

input:

2 5 3
01000
00010

output:

-1

result:

ok single line: '-1'

Test #5:

score: 0
Accepted
time: 6ms
memory: 22200kb

input:

1 5 3
11111

output:

-1

result:

ok single line: '-1'

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 22240kb

input:

10 5 3
000010000100
0001000010000100001
000100
00010
00010000100
0010
00001000010000100001000010
00010
001
001000010

output:

-1

result:

wrong answer 1st lines differ - expected: '6 2 1 9 7 3 10 4 8 5', found: '-1'