QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#73283 | #1439. Football Match | zhangboju# | AC ✓ | 2ms | 3744kb | C++14 | 1.2kb | 2023-01-23 14:22:29 | 2023-01-23 14:22:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
template <typename T> inline void read(T &x)
{
x=0;short f=1;char c=getchar();
for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
x*=f;return;
}
const int N=55;
int n,m;
int a[N];
char s[N];
int main()
{
cin>>n>>s+1;
for(int i=1;i<=n;++i)
m+=s[i]=='Y';
int num=0,sum=0;
if(m&1)
{
puts("YES");
if(m==1)
{
int num=0;
for(int i=1;i<=n;++i)
if(s[i]=='Y') printf("%d ",10000);
else if((++num)<n-1) printf("%d ",1);
else printf("%d ",n-2);
return 0;
}
for(int i=1;i<=n;++i)
printf("%d ",s[i]=='Y'?1:2);
return 0;
}
if(m==n-1&&n>=5)
{
puts("YES");
for(int i=1;i<=n;++i)
if(s[i]=='N') printf("%d ",n-2);
else if((++num)<n-1) printf("1 ");
else printf("%d ",(n-2)+(n-2)-1);
return 0;
}
if(m>=n-1)
{
puts("NO");
return 0;
}
for(int i=1;i<=n;++i)
if(s[i]=='N')
{
sum+=1<<num;
++num,num=min(num,2);
}
puts("YES"),num=0;
for(int i=1;i<=n;++i)
{
if(s[i]=='Y')
printf("%d ",sum);
else
{
printf("%d ",1<<num);
++num,num=min(num,2);
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3552kb
input:
4 YNNY
output:
YES 3 1 2 3
result:
ok OK
Test #2:
score: 0
Accepted
time: 2ms
memory: 3548kb
input:
3 NNN
output:
YES 1 2 4
result:
ok OK
Test #3:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
4 NNNN
output:
YES 1 2 4 4
result:
ok OK
Test #4:
score: 0
Accepted
time: 2ms
memory: 3424kb
input:
5 NNNNN
output:
YES 1 2 4 4 4
result:
ok OK
Test #5:
score: 0
Accepted
time: 2ms
memory: 3496kb
input:
3 YNN
output:
YES 10000 1 1
result:
ok OK
Test #6:
score: 0
Accepted
time: 1ms
memory: 3520kb
input:
4 NNYN
output:
YES 1 1 10000 2
result:
ok OK
Test #7:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
5 NNYNN
output:
YES 1 1 10000 1 3
result:
ok OK
Test #8:
score: 0
Accepted
time: 1ms
memory: 3284kb
input:
3 YYN
output:
NO
result:
ok OK
Test #9:
score: 0
Accepted
time: 2ms
memory: 3704kb
input:
4 NNYY
output:
YES 1 2 3 3
result:
ok OK
Test #10:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
5 YNYNN
output:
YES 7 1 7 2 4
result:
ok OK
Test #11:
score: 0
Accepted
time: 1ms
memory: 3552kb
input:
3 YYY
output:
YES 1 1 1
result:
ok OK
Test #12:
score: 0
Accepted
time: 2ms
memory: 3524kb
input:
4 YYNY
output:
YES 1 1 2 1
result:
ok OK
Test #13:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
5 YYNNY
output:
YES 1 1 2 2 1
result:
ok OK
Test #14:
score: 0
Accepted
time: 0ms
memory: 3356kb
input:
4 YYYY
output:
NO
result:
ok OK
Test #15:
score: 0
Accepted
time: 2ms
memory: 3516kb
input:
5 YNYYY
output:
YES 1 3 1 1 5
result:
ok OK
Test #16:
score: 0
Accepted
time: 2ms
memory: 3556kb
input:
5 YYYYY
output:
YES 1 1 1 1 1
result:
ok OK
Test #17:
score: 0
Accepted
time: 2ms
memory: 3588kb
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: 2ms
memory: 3360kb
input:
50 YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
output:
NO
result:
ok OK
Test #19:
score: 0
Accepted
time: 2ms
memory: 3744kb
input:
49 NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
output:
YES 1 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
result:
ok OK
Test #20:
score: 0
Accepted
time: 2ms
memory: 3420kb
input:
50 NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
output:
YES 1 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
result:
ok OK
Test #21:
score: 0
Accepted
time: 1ms
memory: 3548kb
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 2
result:
ok OK
Test #22:
score: 0
Accepted
time: 2ms
memory: 3740kb
input:
49 YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNYYYYYYYYYYYYYYYYY
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 47 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 93
result:
ok OK
Test #23:
score: 0
Accepted
time: 2ms
memory: 3492kb
input:
50 NNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN
output:
YES 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10000 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 #24:
score: 0
Accepted
time: 2ms
memory: 3512kb
input:
49 YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
output:
YES 10000 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 47
result:
ok OK
Test #25:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
37 YNYYYYYYYYYNYNNYYNNNYYYNNYNYNYNYYYNNY
output:
YES 1 2 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: 2ms
memory: 3544kb
input:
4 NYNN
output:
YES 1 10000 1 2
result:
ok OK
Test #27:
score: 0
Accepted
time: 2ms
memory: 3488kb
input:
29 NNYNNNNNNNNYNNNNNNNNNNNNNNNNN
output:
YES 1 2 103 4 4 4 4 4 4 4 4 103 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
result:
ok OK
Test #28:
score: 0
Accepted
time: 2ms
memory: 3500kb
input:
21 YYYYNYYNYYYYYNYNYNYYN
output:
YES 1 1 1 1 2 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: 3484kb
input:
12 YYYYYNYYYYYY
output:
YES 1 1 1 1 1 2 1 1 1 1 1 1
result:
ok OK
Test #30:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
14 NYYYYYNYYYYYYY
output:
YES 1 3 3 3 3 3 2 3 3 3 3 3 3 3
result:
ok OK
Test #31:
score: 0
Accepted
time: 2ms
memory: 3556kb
input:
9 YYYYYYNNN
output:
YES 7 7 7 7 7 7 1 2 4
result:
ok OK
Test #32:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
48 NNNNYYNNYNNNNNNYNNNNNNNNNNYYNNNNNNNYNNNNNNNNNNNN
output:
YES 2 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: 2ms
memory: 3552kb
input:
12 YYYYNYNYNNNY
output:
YES 1 1 1 1 2 1 2 1 2 2 2 1
result:
ok OK
Test #34:
score: 0
Accepted
time: 2ms
memory: 3516kb
input:
13 NNNNYNYNNNNNN
output:
YES 1 2 4 4 39 4 39 4 4 4 4 4 4
result:
ok OK
Test #35:
score: 0
Accepted
time: 2ms
memory: 3496kb
input:
50 NNNNYYNYYYYNNNNYYNNYYNNNNYNNYYYYNNNNNYYYYNYYNNNYYN
output:
YES 2 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: 2ms
memory: 3608kb
input:
30 YNYNNNNYNNYNNYYNYYYYNNYNNYNNNY
output:
YES 1 2 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: 3524kb
input:
46 NNNNNYNNNNNNYNNNNNNNNNNNNNNNNNYNNNNNNNYNNNNNYN
output:
YES 2 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: 3496kb
input:
16 NYYYYYYNNYYNYYYY
output:
YES 1 11 11 11 11 11 11 2 4 11 11 4 11 11 11 11
result:
ok OK
Test #39:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
8 YYYNYYYY
output:
YES 1 1 1 2 1 1 1 1
result:
ok OK
Test #40:
score: 0
Accepted
time: 2ms
memory: 3512kb
input:
44 YNYNNNNNNYNNNNYNNNNNNNYNNNYYYYNYNYNNYNNNNNNN
output:
YES 123 1 123 2 4 4 4 4 4 123 4 4 4 4 123 4 4 4 4 4 4 4 123 4 4 4 123 123 123 123 4 123 4 123 4 4 123 4 4 4 4 4 4 4
result:
ok OK
Test #41:
score: 0
Accepted
time: 2ms
memory: 3528kb
input:
42 NYYYYYNNNNNNNNYNNYYYYYYNYYYYYNYYYYYYYNYYNN
output:
YES 1 59 59 59 59 59 2 4 4 4 4 4 4 4 59 4 4 59 59 59 59 59 59 4 59 59 59 59 59 4 59 59 59 59 59 59 59 4 59 59 4 4
result:
ok OK
Test #42:
score: 0
Accepted
time: 2ms
memory: 3528kb
input:
15 NYNNNNYYYNNNYYY
output:
YES 2 1 2 2 2 2 1 1 1 2 2 2 1 1 1
result:
ok OK
Test #43:
score: 0
Accepted
time: 2ms
memory: 3528kb
input:
21 NNNYNYYYYNYYNYYYNYYYY
output:
YES 1 2 4 23 4 23 23 23 23 4 23 23 4 23 23 23 4 23 23 23 23
result:
ok OK
Test #44:
score: 0
Accepted
time: 2ms
memory: 3716kb
input:
23 YYYYYNYNNYNNNNYNYYNNYYN
output:
YES 39 39 39 39 39 1 39 2 4 39 4 4 4 4 39 4 39 39 4 4 39 39 4
result:
ok OK
Test #45:
score: 0
Accepted
time: 2ms
memory: 3528kb
input:
29 YYYYYNNYYYYNNNNYYNNNYYNNYNNNN
output:
YES 55 55 55 55 55 1 2 55 55 55 55 4 4 4 4 55 55 4 4 4 55 55 4 4 55 4 4 4 4
result:
ok OK
Test #46:
score: 0
Accepted
time: 2ms
memory: 3548kb
input:
38 YYNNNYYYNNNYYNNNNNNYNNNNNNYYYYNNNNNNNY
output:
YES 1 1 2 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: 2ms
memory: 3700kb
input:
4 NYYY
output:
YES 2 1 1 1
result:
ok OK
Test #48:
score: 0
Accepted
time: 2ms
memory: 3736kb
input:
39 NNYYYYYYYNYYYYYYYYYYYYYYYYYYYYYYYNYNYYY
output:
YES 1 2 15 15 15 15 15 15 15 4 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 4 15 4 15 15 15
result:
ok OK
Test #49:
score: 0
Accepted
time: 2ms
memory: 3484kb
input:
14 NNNYNNNNNNNNNN
output:
YES 1 1 1 10000 1 1 1 1 1 1 1 1 1 12
result:
ok OK
Test #50:
score: 0
Accepted
time: 2ms
memory: 3740kb
input:
48 YNNNNYYYYNYYNNYYYYNNYNNYNYYYYYYNYYYYNNNNYNYNNNNN
output:
YES 1 2 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: 2ms
memory: 3520kb
input:
30 NNNNNNNYYNYNNNNYNNNYNNNNYNNNYY
output:
YES 1 2 4 4 4 4 4 83 83 4 83 4 4 4 4 83 4 4 4 83 4 4 4 4 83 4 4 4 83 83
result:
ok OK
Test #52:
score: 0
Accepted
time: 2ms
memory: 3424kb
input:
36 YNYYYYYNYNNNYNYYNYYNYNNYNNYYNNNYYNYN
output:
YES 1 2 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: 2ms
memory: 3696kb
input:
26 YNYYYYYYYYYNYYYNYYYYYYYYYY
output:
YES 1 2 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: 3588kb
input:
33 YNNYNNNNNYYYYNNNNYYNYNNYNNYNNYNYN
output:
YES 1 2 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