CSES - Datatähti 2024 loppu - Results
Submission details
Task:Sukat
Sender:vgtcross
Submission time:2024-01-20 13:10:16 +0200
Language:C++ (C++20)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.00 s1, 2, 3details
#20.00 s1, 2, 3details
#30.00 s1, 2, 3details
#40.00 s1, 2, 3details
#50.00 s1, 2, 3details
#60.00 s1, 2, 3details
#70.00 s1, 2, 3details
#80.00 s2, 3details
#90.00 s2, 3details
#100.00 s2, 3details
#110.00 s2, 3details
#120.00 s2, 3details
#130.00 s2, 3details
#140.00 s2, 3details
#150.03 s3details
#160.01 s3details
#170.04 s3details
#180.03 s3details
#190.03 s3details
#200.03 s3details
#210.01 s3details

Compiler report

input/code.cpp: In function 'void solve()':
input/code.cpp:16:26: warning: array subscript has type 'char' [-Wchar-subscripts]
   16 |     for (char c : s) ++f[c];
      |                          ^
input/code.cpp:19:62: warning: array subscript has type 'char' [-Wchar-subscripts]
   19 |     for (char c = 'A'; c <= 'Z'; ++c) cout << c << ": " << f[c] << endl;
      |                                                              ^
input/code.cpp:22:45: warning: array subscript has type 'char' [-Wchar-subscripts]
   22 |     for (char c = 'A'; c <= 'Z'; ++c) if (f[c] != 0) st.insert({f[c], c});
      |                                             ^
input/code.cpp:22:67: warning: array subscript has type 'char' [-Wchar-subscripts]
   22 |     for (char c = 'A'; c <= 'Z'; ++c) if (f[c] != 0) st.insert({f[c], c});
      |                                                                   ^
input/code.cpp: In lambda function:
input/code.cpp:25:21: warning: array subscript has type 'char' [-Wch...

Code

#include <bits/stdc++.h>

#define fi first
#define se second

using namespace std;
using ll = long long;
using pic = pair<int, char>;

void solve() {
    string s;
    cin >> s;

    int n = s.size();
    int f[128] = {};
    for (char c : s) ++f[c];


    for (char c = 'A'; c <= 'Z'; ++c) cout << c << ": " << f[c] << endl;

    set<pic> st;
    for (char c = 'A'; c <= 'Z'; ++c) if (f[c] != 0) st.insert({f[c], c});
    
    auto remove = [&](char c) {
        st.erase({f[c], c});
        if (--f[c] > 0) st.insert({f[c], c});
    };

    vector<pair<char, char>> ans;
    while (st.size() >= 2) {
        auto it = st.end();
        --it;
        auto it2 = it;
        --it2;
        char c = it->se;
        char d = it2->se;
        ans.push_back({c, d});
        remove(c);
        remove(d);
    }

    cout << ans.size() << '\n';
    for (auto &s : ans) cout << s.fi << s.se << '\n';
}

int main() {
    cin.tie(0) -> sync_with_stdio(0);

    solve();

    return 0;
}

Test details

Test 1

Group: 1, 2, 3

Verdict:

input
QBAXGXJZJS

correct output
5
XJ
ZX
SQ
JG
...

user output
A: 1
B: 1
C: 0
D: 0
E: 0
...
Truncated

Test 2

Group: 1, 2, 3

Verdict:

input
SSSSSSSSSS

correct output
0

user output
A: 0
B: 0
C: 0
D: 0
E: 0
...
Truncated

Test 3

Group: 1, 2, 3

Verdict:

input
SETTSESEEE

correct output
5
ES
ET
ES
ET
...

user output
A: 0
B: 0
C: 0
D: 0
E: 5
...
Truncated

Test 4

Group: 1, 2, 3

Verdict:

input
SSMRSSSSKR

correct output
4
SR
SR
SM
SK

user output
A: 0
B: 0
C: 0
D: 0
E: 0
...
Truncated

Test 5

Group: 1, 2, 3

Verdict:

input
BIIILIIRRL

correct output
5
IR
IL
IR
IL
...

user output
A: 0
B: 1
C: 0
D: 0
E: 0
...
Truncated

Test 6

Group: 1, 2, 3

Verdict:

input
YYGEYTDSTY

correct output
5
YT
YT
YS
YG
...

user output
A: 0
B: 0
C: 0
D: 1
E: 1
...
Truncated

Test 7

Group: 1, 2, 3

Verdict:

input
MMMMMMMMMN

correct output
1
MN

user output
A: 0
B: 0
C: 0
D: 0
E: 0
...
Truncated

Test 8

Group: 2, 3

Verdict:

input
XQQZJQDDJOWXDFVQUIODDJIZIQDQIW...

correct output
500
DQ
DQ
DQ
DQ
...

user output
A: 0
B: 44
C: 25
D: 253
E: 0
...
Truncated

Test 9

Group: 2, 3

Verdict:

input
IIIIIIIIIIIIIIIIIIIIIIIIIIIIII...

correct output
0

user output
A: 0
B: 0
C: 0
D: 0
E: 0
...
Truncated

Test 10

Group: 2, 3

Verdict:

input
KEOHHYHHAIHLLHEKIHKAHHHHOHEHHE...

correct output
493
HA
HA
HA
HA
...

user output
A: 65
B: 0
C: 29
D: 24
E: 53
...
Truncated

Test 11

Group: 2, 3

Verdict:

input
WNNFXQNODQFSQVQQPNLQNQNNVVNXHN...

correct output
499
NQ
NQ
NQ
NQ
...

user output
A: 23
B: 0
C: 0
D: 30
E: 6
...
Truncated

Test 12

Group: 2, 3

Verdict:

input
VGAHMMMXMMVXAAMMMOMMMXVMMMYMXT...

correct output
500
MH
MH
MH
MH
...

user output
A: 48
B: 0
C: 27
D: 8
E: 0
...
Truncated

Test 13

Group: 2, 3

Verdict:

input
KKKKUUAKKAUKKKKFKKSVKCWKKKCVOJ...

correct output
500
KI
KI
KI
KI
...

user output
A: 37
B: 12
C: 36
D: 5
E: 3
...
Truncated

Test 14

Group: 2, 3

Verdict:

input
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVV...

correct output
100
VP
VP
VP
VP
...

user output
A: 0
B: 0
C: 0
D: 0
E: 2
...
Truncated

Test 15

Group: 3

Verdict:

input
FKKJJBWTSFCDEKFPOKIPWZSVKHACMC...

correct output
100000
CK
CK
CK
CK
...

user output
A: 5760
B: 6915
C: 28301
D: 16760
E: 4060
...
Truncated

Test 16

Group: 3

Verdict:

input
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

correct output
0

user output
A: 0
B: 0
C: 0
D: 0
E: 0
...
Truncated

Test 17

Group: 3

Verdict:

input
WVKKVVADNVCVKLVYVVZVKVCTNKVLVV...

correct output
99925
VC
VC
VC
VC
...

user output
A: 3676
B: 2736
C: 20040
D: 5581
E: 1841
...
Truncated

Test 18

Group: 3

Verdict:

input
BBBBBDNXDZQXBBYBBWBSBTMADXBBVZ...

correct output
99999
BE
BE
BE
BE
...

user output
A: 2481
B: 100001
C: 620
D: 8108
E: 18765
...
Truncated

Test 19

Group: 3

Verdict:

input
FBRDPLUMLZMLLLUFUCLEMCMULLZLFL...

correct output
100000
LU
LU
LU
LU
...

user output
A: 199
B: 2452
C: 10571
D: 5258
E: 2356
...
Truncated

Test 20

Group: 3

Verdict:

input
UUBUBUTUJSLUVBUXTUUMUXUXTMXUXS...

correct output
100000
UX
UX
UX
UX
...

user output
A: 314
B: 10092
C: 408
D: 1260
E: 702
...
Truncated

Test 21

Group: 3

Verdict:

input
PPPPPPPPPPEPPPPPPPPPPBOPPPPPPP...

correct output
20000
PB
PB
PB
PB
...

user output
A: 1596
B: 4934
C: 568
D: 1453
E: 945
...
Truncated