QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#225920 | #1439. Football Match | ucup-team1209# | AC ✓ | 1ms | 3864kb | C++20 | 2.4kb | 2023-10-25 11:47:01 | 2023-10-25 11:47:01 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define drep(i,y,x) for (int i=(y);i>=(x);i--)
#define pii pair<int,int>
#define fir first
#define sec second
#define MP make_pair
template<typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template<typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}
void file() {
#ifdef zqj
freopen("a.in","r",stdin);
#endif
}
#define sz 233
int n;
char s[sz];
int c[2];
void output(vector<int>*v) {
cout<<"YES\n";
static int a[sz];
rep(i,0,n-1) {
int t=(s[i]=='Y');
cout<<(a[i]=v[t].back())<<' ';
v[t].pop_back();
}
// rep(i,0,n-1) {
// vector<int>vv;
// int sum=0;
// rep(j,0,n-1) if (j!=i) vv.push_back(a[j]),sum+=a[j];
// bitset<sz*sz>dp;
// dp[0]=1;
// for (auto x:vv) dp|=dp<<x;
// int ok=(sum%2==0&&dp[sum/2]==1);
// assert(ok==(s[i]=='Y'));
// }
exit(0);
}
int main() {
file();
// mt19937 rng(time(0)+(size_t)(new char));
// n=rng()%10+3;
// rep(i,0,n-1) s[i]="YN"[rng()%2];
// cerr<<s<<'\n';
cin>>n;
cin>>s;
rep(i,0,n-1) c[s[i]=='Y']++;
if (!c[0]) {
if (n%2==0) return cout<<"NO\n",0;
cout<<"YES\n";
rep(i,0,n-1) cout<<1<<" \n"[i==n-1];
return 0;
}
if (c[1]==1&&c[0]%2==1) {
vector<int>v[2];
rep(i,1,c[0]-1) v[0].push_back(2);
v[0].push_back(4);
v[1].push_back(1);
output(v);
}
if (c[1]%2==0&&c[0]==1) {
if (c[1]==2) return cout<<"NO\n",0;
vector<int>v[2];
v[0].push_back(3);
rep(i,1,c[1]-1) v[1].push_back(1);
v[1].push_back(c[1]+1);
output(v);
}
if (c[1]%2==1) {
assert(!(c[1]==1&&c[0]%2==1));
vector<int>v[2]={vector<int>(c[0],2),vector<int>(c[1],1)};
output(v);
}
if (c[1]%2==0&&c[0]%2==1) {
assert(!(c[0]==1));
vector<int>v[2];
int sum=3;
v[0].push_back(1),v[0].push_back(2);
rep(i,3,c[0]) v[0].push_back(4),sum+=4;
v[1]=vector<int>(c[1],sum);
output(v);
}
if (c[1]%2==0&&c[0]%2==0) {
assert(!(c[0]==0));
vector<int>v[2]={vector<int>(c[0],1),vector<int>(c[1],2)};
output(v);
}
assert(0);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
4 YNNY
output:
YES 2 1 1 2
result:
ok OK
Test #2:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
3 NNN
output:
YES 4 2 1
result:
ok OK
Test #3:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
4 NNNN
output:
YES 1 1 1 1
result:
ok OK
Test #4:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
5 NNNNN
output:
YES 4 4 4 2 1
result:
ok OK
Test #5:
score: 0
Accepted
time: 0ms
memory: 3628kb
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: 3564kb
input:
5 NNYNN
output:
YES 2 2 1 2 2
result:
ok OK
Test #8:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
3 YYN
output:
NO
result:
ok OK
Test #9:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
4 NNYY
output:
YES 1 1 2 2
result:
ok OK
Test #10:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
5 YNYNN
output:
YES 7 4 7 2 1
result:
ok OK
Test #11:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
3 YYY
output:
YES 1 1 1
result:
ok OK
Test #12:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
4 YYNY
output:
YES 1 1 2 1
result:
ok OK
Test #13:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
5 YYNNY
output:
YES 1 1 2 2 1
result:
ok OK
Test #14:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
4 YYYY
output:
NO
result:
ok OK
Test #15:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
5 YNYYY
output:
YES 5 3 1 1 1
result:
ok OK
Test #16:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
5 YYYYY
output:
YES 1 1 1 1 1
result:
ok OK
Test #17:
score: 0
Accepted
time: 0ms
memory: 3628kb
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: 3628kb
input:
50 YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
output:
NO
result:
ok OK
Test #19:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
49 NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
output:
YES 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 2 1
result:
ok OK
Test #20:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
50 NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
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 1
result:
ok OK
Test #21:
score: 0
Accepted
time: 0ms
memory: 3824kb
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: 0ms
memory: 3560kb
input:
49 YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYNYYYYYYYYYYYYYYYYY
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 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
result:
ok OK
Test #23:
score: 0
Accepted
time: 0ms
memory: 3508kb
input:
50 NNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN
output:
YES 4 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: 3824kb
input:
49 YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
output:
YES 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 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: 3864kb
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: 0ms
memory: 3624kb
input:
4 NYNN
output:
YES 4 1 2 2
result:
ok OK
Test #27:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
29 NNYNNNNNNNNYNNNNNNNNNNNNNNNNN
output:
YES 4 4 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 2 1
result:
ok OK
Test #28:
score: 0
Accepted
time: 0ms
memory: 3516kb
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: 3512kb
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: 0ms
memory: 3624kb
input:
14 NYYYYYNYYYYYYY
output:
YES 1 2 2 2 2 2 1 2 2 2 2 2 2 2
result:
ok OK
Test #31:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
9 YYYYYYNNN
output:
YES 7 7 7 7 7 7 4 2 1
result:
ok OK
Test #32:
score: 0
Accepted
time: 0ms
memory: 3624kb
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: 0ms
memory: 3620kb
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: 0ms
memory: 3860kb
input:
13 NNNNYNYNNNNNN
output:
YES 4 4 4 4 39 4 39 4 4 4 4 2 1
result:
ok OK
Test #35:
score: 0
Accepted
time: 0ms
memory: 3556kb
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: 0ms
memory: 3512kb
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: 3620kb
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: 3508kb
input:
16 NYYYYYYNNYYNYYYY
output:
YES 1 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: 3624kb
input:
8 YYYNYYYY
output:
YES 1 1 1 2 1 1 1 1
result:
ok OK
Test #40:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
44 YNYNNNNNNYNNNNYNNNNNNNYNNNYYYYNYNYNNYNNNNNNN
output:
YES 2 1 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: 3568kb
input:
42 NYYYYYNNNNNNNNYNNYYYYYYNYYYYYNYYYYYYYNYYNN
output:
YES 1 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: 3624kb
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: 0ms
memory: 3856kb
input:
21 NNNYNYYYYNYYNYYYNYYYY
output:
YES 4 4 4 23 4 23 23 23 23 4 23 23 2 23 23 23 1 23 23 23 23
result:
ok OK
Test #44:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
23 YYYYYNYNNYNNNNYNYYNNYYN
output:
YES 39 39 39 39 39 4 39 4 4 39 4 4 4 4 39 4 39 39 4 2 39 39 1
result:
ok OK
Test #45:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
29 YYYYYNNYYYYNNNNYYNNNYYNNYNNNN
output:
YES 55 55 55 55 55 4 4 55 55 55 55 4 4 4 4 55 55 4 4 4 55 55 4 4 55 4 4 2 1
result:
ok OK
Test #46:
score: 0
Accepted
time: 0ms
memory: 3856kb
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: 0ms
memory: 3600kb
input:
4 NYYY
output:
YES 2 1 1 1
result:
ok OK
Test #48:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
39 NNYYYYYYYNYYYYYYYYYYYYYYYYYYYYYYYNYNYYY
output:
YES 4 4 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 2 15 1 15 15 15
result:
ok OK
Test #49:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
14 NNNYNNNNNNNNNN
output:
YES 4 2 2 1 2 2 2 2 2 2 2 2 2 2
result:
ok OK
Test #50:
score: 0
Accepted
time: 0ms
memory: 3828kb
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: 0ms
memory: 3616kb
input:
30 NNNNNNNYYNYNNNNYNNNYNNNNYNNNYY
output:
YES 1 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: 3628kb
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: 0ms
memory: 3856kb
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: 3596kb
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