QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#124847#1439. Football Match8BQube#AC ✓1ms3500kbC++202.2kb2023-07-15 16:33:452023-07-15 16:33:46

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-15 16:33:46]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3500kb
  • [2023-07-15 16:33:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(), v.end()
#define pb push_back

void no() {
    cout << "NO\n";
    exit(0);
}
void yes(const vector<int> &v) {
    cout << "YES\n";  
    for (int i = 0; i < SZ(v); i++)
        cout << v[i] << " \n"[i + 1 == SZ(v)];
    exit(0);
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int N;
    string s;
    cin >> N >> s;
    int nN = 0, nY = 0;
    for (char c : s)
        if (c == 'N')
            nN++;
        else
            nY++;

    if (nY & 1) {
        if (nY == 1 && (nN & 1))  {
            vector<int> v;
            bool fg = 0;
            for (char c : s)
                if (c == 'Y')
                    v.pb(2 * nN);
                else if (!fg)
                    v.pb(nN - 1), fg = 1;
                else
                    v.pb(1);
            yes(v);
        }
        else {
            vector<int> v;
            for (char c : s)
                if (c == 'Y')
                    v.pb(1);
                else
                    v.pb(2);
            yes(v);
        }
    }
    else {
        if (!nN)
            no();
        else if (nN % 2 == 0) {
            vector<int> v;
            for (char c : s)
                if (c == 'Y')
                    v.pb(2);
                else
                    v.pb(1);
            yes(v);
        }
        else if (nY >= 4) {
            int a = nY - 1;
            vector<int> v;
            for (char c : s)
                if (c == 'N')
                    v.pb(a);
                else if (nY >= 2)
                    v.pb(1), nY--;
                else
                    v.pb((N - a - 1) * a + (a - 1));
            yes(v);
        }
        else if (nN == 1)
            no();
        else {
            int k = nN - 2;
            vector<int> v;
            for (char c : s)
                if (c == 'Y')
                    v.pb(k + k + 2 + 2);
                else if (nN >= 3)
                    v.pb(1), nN--;
                else if (nN == 2)
                    v.pb(k + 2), nN--;
                else
                    v.pb(2);
            yes(v);
        }
    }

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
YNNY

output:

YES
2 1 1 2

result:

ok OK

Test #2:

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

input:

3
NNN

output:

YES
1 3 2

result:

ok OK

Test #3:

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

input:

4
NNNN

output:

YES
1 1 1 1

result:

ok OK

Test #4:

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

input:

5
NNNNN

output:

YES
1 1 1 5 2

result:

ok OK

Test #5:

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

input:

3
YNN

output:

YES
1 2 2

result:

ok OK

Test #6:

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

input:

4
NNYN

output:

YES
2 1 6 1

result:

ok OK

Test #7:

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

input:

5
NNYNN

output:

YES
2 2 1 2 2

result:

ok OK

Test #8:

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

input:

3
YYN

output:

NO

result:

ok OK

Test #9:

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

input:

4
NNYY

output:

YES
1 1 2 2

result:

ok OK

Test #10:

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

input:

5
YNYNN

output:

YES
6 1 6 3 2

result:

ok OK

Test #11:

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

input:

3
YYY

output:

YES
1 1 1

result:

ok OK

Test #12:

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

input:

4
YYNY

output:

YES
1 1 2 1

result:

ok OK

Test #13:

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

input:

5
YYNNY

output:

YES
1 1 2 2 1

result:

ok OK

Test #14:

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

input:

4
YYYY

output:

NO

result:

ok OK

Test #15:

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

input:

5
YNYYY

output:

YES
1 3 1 1 5

result:

ok OK

Test #16:

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

input:

5
YYYYY

output:

YES
1 1 1 1 1

result:

ok OK

Test #17:

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

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: 1ms
memory: 3428kb

input:

50
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

output:

NO

result:

ok OK

Test #19:

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

input:

49
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN

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 49 2

result:

ok OK

Test #20:

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

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: 1ms
memory: 3400kb

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: 1ms
memory: 3440kb

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: 1ms
memory: 3404kb

input:

50
NNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN

output:

YES
48 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 98 1 1 1 1 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 #24:

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

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: 1ms
memory: 3424kb

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: 1ms
memory: 3400kb

input:

4
NYNN

output:

YES
2 6 1 1

result:

ok OK

Test #27:

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

input:

29
NNYNNNNNNNNYNNNNNNNNNNNNNNNNN

output:

YES
1 1 54 1 1 1 1 1 1 1 1 54 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 27 2

result:

ok OK

Test #28:

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

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: 1ms
memory: 3468kb

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: 3392kb

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: 1ms
memory: 3500kb

input:

9
YYYYYYNNN

output:

YES
1 1 1 1 1 19 5 5 5

result:

ok OK

Test #32:

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

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: 1ms
memory: 3400kb

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: 1ms
memory: 3400kb

input:

13
NNNNYNYNNNNNN

output:

YES
1 1 1 1 22 1 22 1 1 1 1 11 2

result:

ok OK

Test #35:

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

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: 1ms
memory: 3448kb

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: 1ms
memory: 3404kb

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: 1ms
memory: 3420kb

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: 1ms
memory: 3440kb

input:

8
YYYNYYYY

output:

YES
1 1 1 2 1 1 1 1

result:

ok OK

Test #40:

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

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: 1ms
memory: 3472kb

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: 1ms
memory: 3460kb

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: 1ms
memory: 3400kb

input:

21
NNNYNYYYYNYYNYYYNYYYY

output:

YES
13 13 13 1 13 1 1 1 1 13 1 1 13 1 1 1 13 1 1 1 103

result:

ok OK

Test #44:

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

input:

23
YYYYYNYNNYNNNNYNYYNNYYN

output:

YES
1 1 1 1 1 11 1 11 11 1 11 11 11 11 1 11 1 1 11 11 1 131 11

result:

ok OK

Test #45:

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

input:

29
YYYYYNNYYYYNNNNYYNNNYYNNYNNNN

output:

YES
1 1 1 1 1 13 13 1 1 1 1 13 13 13 13 1 1 13 13 13 1 1 13 13 207 13 13 13 13

result:

ok OK

Test #46:

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

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: 1ms
memory: 3388kb

input:

4
NYYY

output:

YES
2 1 1 1

result:

ok OK

Test #48:

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

input:

39
NNYYYYYYYNYYYYYYYYYYYYYYYYYYYYYYYNYNYYY

output:

YES
33 33 1 1 1 1 1 1 1 33 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 33 1 33 1 1 197

result:

ok OK

Test #49:

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

input:

14
NNNYNNNNNNNNNN

output:

YES
12 1 1 26 1 1 1 1 1 1 1 1 1 1

result:

ok OK

Test #50:

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

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: 1ms
memory: 3448kb

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: 1ms
memory: 3404kb

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: 3476kb

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: 1ms
memory: 3444kb

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