QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#123775#1439. Football Matchckiseki#AC ✓1ms3500kbC++202.6kb2023-07-13 16:23:032023-07-13 16:23:06

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-13 16:23:06]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3500kb
  • [2023-07-13 16:23:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#ifdef CKISEKI
#define all(x) begin(x), end(x)
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
template <typename ...T>
void debug_(const char *s, T ...a) {
    cerr << "\e[1;32m(" << s << ") = (";
    int cnt = sizeof...(T);
    (..., (cerr << a << (--cnt ? ", " : ")\e[0m\n")));
}
template <typename I>
void orange_(const char *s, I L, I R) {
    cerr << "\e[1;32m[ " << s << " ] = [";
    while (L != R) cerr << " " << *L++;
    cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cN = 0, cY = 0;
    for (auto c : s) {
        if (c == 'N') cN++;
        else cY++;
    }
    if (cN == 1) {
        if (cY <= 2) {
            cout << "NO\n";
            return 0;
        }
        cout << "YES\n";
        int tot = cY;
        for (int i = 0; i < n; ++i) {
            if (s[i] == 'Y') {
                if (cY-- == 1) {
                    cout << 2 * tot - 3;
                } else {
                    cout << 1;
                }
            } else {
                cout << tot - 1;
            }
            cout << " \n"[i + 1 == n];
        }
    } else if (cY % 2 == 0) { 
        if (cN == 0) {
            cout << "NO\n";
            return 0;
        }
        cout << "YES\n";
        if (cN % 2 == 0) {
            for (int i = 0; i < n; ++i) {
                if (s[i] == 'Y') cout << cN;
                else cout << 1;
                cout << " \n"[i + 1 == n];
            }
        } else {
            int x = 2 * cN - 1;
            int y = 2 * cN;
            int k = 2 * (cN - 2) + x + y;
            for (int i = 0; i < n; ++i) {
                if (s[i] == 'Y') cout << k;
                else {
                    if (cN == 2) cout << x;
                    else if (cN == 1) cout << y;
                    else cout << 2;
                    cN -= 1;
                }
                cout << " \n"[i + 1 == n];
            }
        }
    } else {
        cout << "YES\n";
        if (cN == 0) {
            for (int i = 0; i < n; ++i)
                cout << 1 << " \n"[i + 1 == n];
            return 0;
        }
        int x = (cN - 1) * 2;
        int y = cN - 1;
        for (int i = 0; i < n; ++i) {
            if (s[i] == 'Y') cout << x;
            else {
                if (cN-- == 1) cout << y;
                else cout << 1;
            }
            cout << " \n"[i + 1 == n];
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
YNNY

output:

YES
2 1 1 2

result:

ok OK

Test #2:

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

input:

3
NNN

output:

YES
2 5 6

result:

ok OK

Test #3:

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

input:

4
NNNN

output:

YES
1 1 1 1

result:

ok OK

Test #4:

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

input:

5
NNNNN

output:

YES
2 2 2 9 10

result:

ok OK

Test #5:

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

input:

3
YNN

output:

YES
2 1 1

result:

ok OK

Test #6:

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

input:

4
NNYN

output:

YES
1 1 4 2

result:

ok OK

Test #7:

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

input:

5
NNYNN

output:

YES
1 1 6 1 3

result:

ok OK

Test #8:

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

input:

3
YYN

output:

NO

result:

ok OK

Test #9:

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

input:

4
NNYY

output:

YES
1 1 2 2

result:

ok OK

Test #10:

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

input:

5
YNYNN

output:

YES
13 2 13 5 6

result:

ok OK

Test #11:

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

input:

3
YYY

output:

YES
1 1 1

result:

ok OK

Test #12:

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

input:

4
YYNY

output:

YES
1 1 2 3

result:

ok OK

Test #13:

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

input:

5
YYNNY

output:

YES
2 2 1 1 2

result:

ok OK

Test #14:

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

input:

4
YYYY

output:

NO

result:

ok OK

Test #15:

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

input:

5
YNYYY

output:

YES
1 3 1 1 5

result:

ok OK

Test #16:

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

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

input:

50
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

output:

NO

result:

ok OK

Test #19:

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

input:

49
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN

output:

YES
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 97 98

result:

ok OK

Test #20:

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

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

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 95 48

result:

ok OK

Test #22:

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

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

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

input:

49
YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN

output:

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

input:

37
YNYYYYYYYYYNYNNYYNNNYYYNNYNYNYNYYYNNY

output:

YES
26 1 26 26 26 26 26 26 26 26 26 1 26 1 1 26 26 1 1 1 26 26 26 1 1 26 1 26 1 26 1 26 26 26 1 13 26

result:

ok OK

Test #26:

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

input:

4
NYNN

output:

YES
1 4 1 2

result:

ok OK

Test #27:

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

input:

29
NNYNNNNNNNNYNNNNNNNNNNNNNNNNN

output:

YES
2 2 157 2 2 2 2 2 2 2 2 157 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 53 54

result:

ok OK

Test #28:

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

input:

21
YYYYNYYNYYYYYNYNYNYYN

output:

YES
10 10 10 10 1 10 10 1 10 10 10 10 10 1 10 1 10 1 10 10 5

result:

ok OK

Test #29:

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

input:

12
YYYYYNYYYYYY

output:

YES
1 1 1 1 1 10 1 1 1 1 1 19

result:

ok OK

Test #30:

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

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

input:

9
YYYYYYNNN

output:

YES
13 13 13 13 13 13 2 5 6

result:

ok OK

Test #32:

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

input:

48
NNNNYYNNYNNNNNNYNNNNNNNNNNYYNNNNNNNYNNNNNNNNNNNN

output:

YES
1 1 1 1 80 80 1 1 80 1 1 1 1 1 1 80 1 1 1 1 1 1 1 1 1 1 80 80 1 1 1 1 1 1 1 80 1 1 1 1 1 1 1 1 1 1 1 40

result:

ok OK

Test #33:

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

input:

12
YYYYNYNYNNNY

output:

YES
8 8 8 8 1 8 1 8 1 1 4 8

result:

ok OK

Test #34:

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

input:

13
NNNNYNYNNNNNN

output:

YES
2 2 2 2 61 2 61 2 2 2 2 21 22

result:

ok OK

Test #35:

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

input:

50
NNNNYYNYYYYNNNNYYNNYYNNNNYNNYYYYNNNNNYYYYNYYNNNYYN

output:

YES
1 1 1 1 52 52 1 52 52 52 52 1 1 1 1 52 52 1 1 52 52 1 1 1 1 52 1 1 52 52 52 52 1 1 1 1 1 52 52 52 52 1 52 52 1 1 1 52 52 26

result:

ok OK

Test #36:

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

input:

30
YNYNNNNYNNYNNYYNYYYYNNYNNYNNNY

output:

YES
32 1 32 1 1 1 1 32 1 1 32 1 1 32 32 1 32 32 32 32 1 1 32 1 1 32 1 1 16 32

result:

ok OK

Test #37:

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

input:

46
NNNNNYNNNNNNYNNNNNNNNNNNNNNNNNYNNNNNNNYNNNNNYN

output:

YES
1 1 1 1 1 80 1 1 1 1 1 1 80 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 80 1 1 1 1 1 1 1 80 1 1 1 1 1 80 40

result:

ok OK

Test #38:

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

input:

16
NYYYYYYNNYYNYYYY

output:

YES
1 4 4 4 4 4 4 1 1 4 4 1 4 4 4 4

result:

ok OK

Test #39:

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

input:

8
YYYNYYYY

output:

YES
1 1 1 6 1 1 1 11

result:

ok OK

Test #40:

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

input:

44
YNYNNNNNNYNNNNYNNNNNNNYNNNYYYYNYNYNNYNNNNNNN

output:

YES
32 1 32 1 1 1 1 1 1 32 1 1 1 1 32 1 1 1 1 1 1 1 32 1 1 1 32 32 32 32 1 32 1 32 1 1 32 1 1 1 1 1 1 1

result:

ok OK

Test #41:

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

input:

42
NYYYYYNNNNNNNNYNNYYYYYYNYYYYYNYYYYYYYNYYNN

output:

YES
1 16 16 16 16 16 1 1 1 1 1 1 1 1 16 1 1 16 16 16 16 16 16 1 16 16 16 16 16 1 16 16 16 16 16 16 16 1 16 16 1 1

result:

ok OK

Test #42:

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

input:

15
NYNNNNYYYNNNYYY

output:

YES
1 14 1 1 1 1 14 14 14 1 1 7 14 14 14

result:

ok OK

Test #43:

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

input:

21
NNNYNYYYYNYYNYYYNYYYY

output:

YES
2 2 2 37 2 37 37 37 37 2 37 37 13 37 37 37 14 37 37 37 37

result:

ok OK

Test #44:

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

input:

23
YYYYYNYNNYNNNNYNYYNNYYN

output:

YES
61 61 61 61 61 2 61 2 2 61 2 2 2 2 61 2 61 61 2 21 61 61 22

result:

ok OK

Test #45:

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

input:

29
YYYYYNNYYYYNNNNYYNNNYYNNYNNNN

output:

YES
85 85 85 85 85 2 2 85 85 85 85 2 2 2 2 85 85 2 2 2 85 85 2 2 85 2 2 29 30

result:

ok OK

Test #46:

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

input:

38
YYNNNYYYNNNYYNNNNNNYNNNNNNYYYYNNNNNNNY

output:

YES
48 48 1 1 1 48 48 48 1 1 1 48 48 1 1 1 1 1 1 48 1 1 1 1 1 1 48 48 48 48 1 1 1 1 1 1 24 48

result:

ok OK

Test #47:

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

input:

4
NYYY

output:

YES
2 1 1 3

result:

ok OK

Test #48:

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

input:

39
NNYYYYYYYNYYYYYYYYYYYYYYYYYYYYYYYNYNYYY

output:

YES
2 2 25 25 25 25 25 25 25 2 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 9 25 10 25 25 25

result:

ok OK

Test #49:

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

input:

14
NNNYNNNNNNNNNN

output:

YES
1 1 1 24 1 1 1 1 1 1 1 1 1 12

result:

ok OK

Test #50:

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

input:

48
YNNNNYYYYNYYNNYYYYNNYNNYNYYYYYYNYYYYNNNNYNYNNNNN

output:

YES
44 1 1 1 1 44 44 44 44 1 44 44 1 1 44 44 44 44 1 1 44 1 1 44 1 44 44 44 44 44 44 1 44 44 44 44 1 1 1 1 44 1 44 1 1 1 1 22

result:

ok OK

Test #51:

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

input:

30
NNNNNNNYYNYNNNNYNNNYNNNNYNNNYY

output:

YES
1 1 1 1 1 1 1 22 22 1 22 1 1 1 1 22 1 1 1 22 1 1 1 1 22 1 1 1 22 22

result:

ok OK

Test #52:

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

input:

36
YNYYYYYNYNNNYNYYNYYNYNNYNNYYNNNYYNYN

output:

YES
32 1 32 32 32 32 32 1 32 1 1 1 32 1 32 32 1 32 32 1 32 1 1 32 1 1 32 32 1 1 1 32 32 1 32 16

result:

ok OK

Test #53:

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

input:

26
YNYYYYYYYYYNYYYNYYYYYYYYYY

output:

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

result:

ok OK

Test #54:

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

input:

33
YNNYNNNNNYYYYNNNNYYNYNNYNNYNNYNYN

output:

YES
38 1 1 38 1 1 1 1 1 38 38 38 38 1 1 1 1 38 38 1 38 1 1 38 1 1 38 1 1 38 1 38 19

result:

ok OK