QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#695266#1439. Football MatchAfterlife#AC ✓0ms3848kbC++202.7kb2024-10-31 19:39:122024-10-31 19:39:19

Judging History

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

  • [2024-10-31 19:39:19]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3848kb
  • [2024-10-31 19:39:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,p,q;
string s;
vector<int> A,B;
vector<int> a;
void check(){
    for(int i=0;i<n;++i){
        bitset<233> dp;
        dp[0]=1;
        int sum=0;
        for(int j=0;j<n;++j){
            if(i==j)continue;
            sum+=a[j];
        }
        if(sum%2==1){
            assert(s[i]=='N');
        }
        else{
            dp[0]=1;
            for(int j=0;j<n;++j){
                if(i==j)continue;
                dp|=dp<<a[j];
            }
            assert((s[i]=='N')^(dp[sum/2]));
        }
    }
}
mt19937 rnd(time(0));
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    cin>>s;
    // n=rnd()%50+1;
    // for(int i=0;i<n;++i){
    //     if(rnd()%2==0)s+='Y';
    //     else s+='N';
    // }
    for(auto c:s){
        if(c=='Y')++p;
        else ++q;
    }
    int sum=0;
    if(p%2==1){
        if(p==1&&q==1){
            cout<<"NO\n";
            return 0;
        }
        for(int i=1;i<=p;++i){
            A.push_back(1);
            sum++;
        }
        if(q>0){
            for(int i=1;i<=q-1;++i){
                B.push_back(2);
                sum+=2;
            }
            sum-=1;
            B.push_back(sum);
        }
    }
    else{
        if(q==0){
            cout<<"NO\n";
            return 0;
        }
        if(q==1){
            
            if(p==2){
                cout<<"NO\n";
            return 0;
            }
            else if(p==4){
                B.push_back(3);
                A.push_back(1);
                A.push_back(5);
                A.push_back(7);
                A.push_back(9);
            }
            else{
                B.push_back(1);
                for(int i=1;i<=3;++i){
                    A.push_back(3);
                }
                for(int i=4;i<=p;++i){
                    A.push_back(5);
                }
            }
        }
        else{
            for(int i=1;i<=p;++i){
                A.push_back(2);
                sum+=2;
            }
            if(q&1){
                B.push_back(4);
                sum+=4;
                --q;
            }
            for(int i=1;i<=q-1;++i){
                B.push_back(1);
                ++sum;
            }
            sum-=2;
            B.push_back(sum);
        }
    }
    cout<<"YES\n";
    for(auto c:s){
        if(c=='Y'){
            a.push_back(A.back());
            cout<<A.back()<<' ';
            A.pop_back();
        }
        else{
            a.push_back(B.back());
            cout<<B.back()<<' ';
            B.pop_back();
        }
    }
    cout<<'\n';
    check();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
YNNY

output:

YES
2 3 1 2 

result:

ok OK

Test #2:

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

input:

3
NNN

output:

YES
3 1 4 

result:

ok OK

Test #3:

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

input:

4
NNNN

output:

YES
1 1 1 1 

result:

ok OK

Test #4:

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

input:

5
NNNNN

output:

YES
5 1 1 1 4 

result:

ok OK

Test #5:

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

input:

3
YNN

output:

YES
1 2 2 

result:

ok OK

Test #6:

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

input:

4
NNYN

output:

YES
4 2 1 2 

result:

ok OK

Test #7:

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

input:

5
NNYNN

output:

YES
6 2 1 2 2 

result:

ok OK

Test #8:

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

input:

3
YYN

output:

NO

result:

ok OK

Test #9:

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

input:

4
NNYY

output:

YES
3 1 2 2 

result:

ok OK

Test #10:

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

input:

5
YNYNN

output:

YES
2 7 2 1 4 

result:

ok OK

Test #11:

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

input:

3
YYY

output:

YES
1 1 1 

result:

ok OK

Test #12:

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

input:

4
YYNY

output:

YES
1 1 2 1 

result:

ok OK

Test #13:

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

input:

5
YYNNY

output:

YES
1 1 4 2 1 

result:

ok OK

Test #14:

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

input:

4
YYYY

output:

NO

result:

ok OK

Test #15:

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

input:

5
YNYYY

output:

YES
9 3 7 5 1 

result:

ok OK

Test #16:

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

input:

5
YYYYY

output:

YES
1 1 1 1 1 

result:

ok OK

Test #17:

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

input:

49
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

output:

YES
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 

result:

ok OK

Test #18:

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

input:

50
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

output:

NO

result:

ok OK

Test #19:

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

input:

49
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN

output:

YES
49 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 

result:

ok OK

Test #20:

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

input:

50
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN

output:

YES
47 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 

result:

ok OK

Test #21:

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

input:

50
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYN

output:

YES
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 48 

result:

ok OK

Test #22:

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

input:

49
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNYYYYYYYYYYYYYYYYY

output:

YES
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 1 5 5 5 5 5 5 5 5 5 5 5 5 5 5 3 3 3 

result:

ok OK

Test #23:

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

input:

50
NNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN

output:

YES
96 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 

result:

ok OK

Test #24:

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

input:

49
YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN

output:

YES
1 94 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 

result:

ok OK

Test #25:

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

input:

37
YNYYYYYYYYYNYNNYYNNNYYYNNYNYNYNYYYNNY

output:

YES
1 48 1 1 1 1 1 1 1 1 1 2 1 2 2 1 1 2 2 2 1 1 1 2 2 1 2 1 2 1 2 1 1 1 2 2 1 

result:

ok OK

Test #26:

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

input:

4
NYNN

output:

YES
4 1 2 2 

result:

ok OK

Test #27:

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

input:

29
NNYNNNNNNNNYNNNNNNNNNNNNNNNNN

output:

YES
31 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 

result:

ok OK

Test #28:

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

input:

21
YYYYNYYNYYYYYNYNYNYYN

output:

YES
1 1 1 1 24 1 1 2 1 1 1 1 1 2 1 2 1 2 1 1 2 

result:

ok OK

Test #29:

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

input:

12
YYYYYNYYYYYY

output:

YES
1 1 1 1 1 10 1 1 1 1 1 1 

result:

ok OK

Test #30:

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

input:

14
NYYYYYNYYYYYYY

output:

YES
23 2 2 2 2 2 1 2 2 2 2 2 2 2 

result:

ok OK

Test #31:

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

input:

9
YYYYYYNNN

output:

YES
2 2 2 2 2 2 15 1 4 

result:

ok OK

Test #32:

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

input:

48
NNNNYYNNYNNNNNNYNNNNNNNNNNYYNNNNNNNYNNNNNNNNNNNN

output:

YES
86 2 2 2 1 1 2 2 1 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 

result:

ok OK

Test #33:

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

input:

12
YYYYNYNYNNNY

output:

YES
1 1 1 1 14 1 2 1 2 2 2 1 

result:

ok OK

Test #34:

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

input:

13
NNNNYNYNNNNNN

output:

YES
15 1 1 1 2 1 2 1 1 1 1 1 4 

result:

ok OK

Test #35:

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

input:

50
NNNNYYNYYYYNNNNYYNNYYNNNNYNNYYYYNNNNNYYYYNYYNNNYYN

output:

YES
74 2 2 2 1 1 2 1 1 1 1 2 2 2 2 1 1 2 2 1 1 2 2 2 2 1 2 2 1 1 1 1 2 2 2 2 2 1 1 1 1 2 1 1 2 2 2 1 1 2 

result:

ok OK

Test #36:

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

input:

30
YNYNNNNYNNYNNYYNYYYYNNYNNYNNNY

output:

YES
1 44 1 2 2 2 2 1 2 2 1 2 2 1 1 2 1 1 1 1 2 2 1 2 2 1 2 2 2 1 

result:

ok OK

Test #37:

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

input:

46
NNNNNYNNNNNNYNNNNNNNNNNNNNNNNNYNNNNNNNYNNNNNYN

output:

YES
84 2 2 2 2 1 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 1 2 

result:

ok OK

Test #38:

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

input:

16
NYYYYYYNNYYNYYYY

output:

YES
25 2 2 2 2 2 2 1 1 2 2 1 2 2 2 2 

result:

ok OK

Test #39:

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

input:

8
YYYNYYYY

output:

YES
1 1 1 6 1 1 1 1 

result:

ok OK

Test #40:

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

input:

44
YNYNNNNNNYNNNNYNNNNNNNYNNNYYYYNYNYNNYNNNNNNN

output:

YES
2 53 2 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 2 1 1 1 2 2 2 2 1 2 1 2 1 1 2 1 1 1 1 1 1 1 

result:

ok OK

Test #41:

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

input:

42
NYYYYYNNNNNNNNYNNYYYYYYNYYYYYNYYYYYYYNYYNN

output:

YES
65 2 2 2 2 2 1 1 1 1 1 1 1 1 2 1 1 2 2 2 2 2 2 1 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 1 1 

result:

ok OK

Test #42:

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

input:

15
NYNNNNYYYNNNYYY

output:

YES
20 1 2 2 2 2 1 1 1 2 2 2 1 1 1 

result:

ok OK

Test #43:

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

input:

21
NNNYNYYYYNYYNYYYNYYYY

output:

YES
35 1 1 2 1 2 2 2 2 1 2 2 1 2 2 2 4 2 2 2 2 

result:

ok OK

Test #44:

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

input:

23
YYYYYNYNNYNNNNYNYYNNYYN

output:

YES
2 2 2 2 2 35 2 1 1 2 1 1 1 1 2 1 2 2 1 1 2 2 4 

result:

ok OK

Test #45:

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

input:

29
YYYYYNNYYYYNNNNYYNNNYYNNYNNNN

output:

YES
2 2 2 2 2 43 1 2 2 2 2 1 1 1 1 2 2 1 1 1 2 2 1 1 2 1 1 1 4 

result:

ok OK

Test #46:

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

input:

38
YYNNNYYYNNNYYNNNNNNYNNNNNNYYYYNNNNNNNY

output:

YES
1 1 60 2 2 1 1 1 2 2 2 1 1 2 2 2 2 2 2 1 2 2 2 2 2 2 1 1 1 1 2 2 2 2 2 2 2 1 

result:

ok OK

Test #47:

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

input:

4
NYYY

output:

YES
2 1 1 1 

result:

ok OK

Test #48:

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

input:

39
NNYYYYYYYNYYYYYYYYYYYYYYYYYYYYYYYNYNYYY

output:

YES
73 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 4 2 2 2 

result:

ok OK

Test #49:

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

input:

14
NNNYNNNNNNNNNN

output:

YES
24 2 2 1 2 2 2 2 2 2 2 2 2 2 

result:

ok OK

Test #50:

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

input:

48
YNNNNYYYYNYYNNYYYYNNYNNYNYYYYYYNYYYYNNNNYNYNNNNN

output:

YES
1 68 2 2 2 1 1 1 1 2 1 1 2 2 1 1 1 1 2 2 1 2 2 1 2 1 1 1 1 1 1 2 1 1 1 1 2 2 2 2 1 2 1 2 2 2 2 2 

result:

ok OK

Test #51:

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

input:

30
NNNNNNNYYNYNNNNYNNNYNNNNYNNNYY

output:

YES
35 1 1 1 1 1 1 2 2 1 2 1 1 1 1 2 1 1 1 2 1 1 1 1 2 1 1 1 2 2 

result:

ok OK

Test #52:

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

input:

36
YNYYYYYNYNNNYNYYNYYNYNNYNNYYNNNYYNYN

output:

YES
1 50 1 1 1 1 1 2 1 2 2 2 1 2 1 1 2 1 1 2 1 2 2 1 2 2 1 1 2 2 2 1 1 2 1 2 

result:

ok OK

Test #53:

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

input:

26
YNYYYYYYYYYNYYYNYYYYYYYYYY

output:

YES
1 26 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 

result:

ok OK

Test #54:

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

input:

33
YNNYNNNNNYYYYNNNNYYNYNNYNNYNNYNYN

output:

YES
1 50 2 1 2 2 2 2 2 1 1 1 1 2 2 2 2 1 1 2 1 2 2 1 2 2 1 2 2 1 2 1 2 

result:

ok OK