CSES - Datatähti 2024 loppu - Results
Submission details
Task:Sukat
Sender:Kemm1706
Submission time:2024-01-20 13:51:35 +0200
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.01 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.01 s3details
#160.01 s3details
#170.00 s3details
#180.00 s3details
#190.00 s3details
#200.00 s3details
#210.01 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:26:31: warning: variable 'pmax' set but not used [-Wunused-but-set-variable]
   26 |     ll l, i, j, k, maxx = -1, pmax;
      |                               ^~~~

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector <ll> vl;
typedef vector <vl> vvl;
typedef pair <ll, ll> pl;
typedef vector <pl> vpl;
typedef vector <bool> vb;

const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll nmax = 1e6;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    string s;
    vpl a(26, {0, 0});
    ll l, i, j, k, maxx = -1, pmax;
    cin >> s;
    l = s.length();
    for(i = 0; i < l; i++)
        a[s[i] - 'A'].fi++;
    for(i = 0; i < 26; i++)
        a[i].se = i;
    for(i = 0; i < l; i++)
        if(a[i].fi > maxx)
        {
            maxx = a[i].fi;
            pmax = i;
        }

    sort(a.begin(), a.end(), greater<pl>());
    cout << min(l / 2, l - maxx) << "\n";

    i = 0, j = 1, k = 25;
    while(i < k && j < k)
    {
        while(a[i].fi > 0 && a[j].fi > 0 && a[k].fi > 0)
        {
            cout << char(a[i].se + 'A') << char(a[k].se + 'A') << "\n";
            if(a[k].fi > 1)
                cout << char(a[j].se + 'A') << char(a[k].se + 'A') << "\n";
            else
            {
                a[k].fi++;
                a[j].fi++;
            }
            a[i].fi--;
            a[j].fi--;
            a[k].fi -= 2;
        }
        if(a[i].fi == 0)
            i = max(i, j) + 1;
        if(a[j].fi == 0)
            j = max(i, j) + 1;
        if(a[k].fi == 0)
            k--;
    }

    while(a[i].fi != 0 && a[j].fi != 0)
    {    cout << char(a[i].se + 'A') << char(a[j].se + 'A') << "\n";
        a[i].fi--;
        a[j].fi--;
    }

    return 0;
}

Test details

Test 1

Group: 1, 2, 3

Verdict:

input
QBAXGXJZJS

correct output
5
XJ
ZX
SQ
JG
...

user output
5
XA
XB
ZG
SQ

Test 2

Group: 1, 2, 3

Verdict:

input
SSSSSSSSSS

correct output
0

user output
5

Test 3

Group: 1, 2, 3

Verdict:

input
SETTSESEEE

correct output
5
ES
ET
ES
ET
...

user output
5
ET
ST
ES
ES

Test 4

Group: 1, 2, 3

Verdict:

input
SSMRSSSSKR

correct output
4
SR
SR
SM
SK

user output
5
SK
SM
SR
SR

Test 5

Group: 1, 2, 3

Verdict:

input
BIIILIIRRL

correct output
5
IR
IL
IR
IL
...

user output
5
IB
IL
RL
IR

Test 6

Group: 1, 2, 3

Verdict:

input
YYGEYTDSTY

correct output
5
YT
YT
YS
YG
...

user output
5
YD
YE
YG
YS

Test 7

Group: 1, 2, 3

Verdict:

input
MMMMMMMMMN

correct output
1
MN

user output
5
MN

Test 8

Group: 2, 3

Verdict:

input
XQQZJQDDJOWXDFVQUIODDJIZIQDQIW...

correct output
500
DQ
DQ
DQ
DQ
...

user output
-6508070091232660322
DG
QG
DN
QN
...
Truncated

Test 9

Group: 2, 3

Verdict:

input
IIIIIIIIIIIIIIIIIIIIIIIIIIIIII...

correct output
0

user output
-5280832617179596129

Test 10

Group: 2, 3

Verdict:

input
KEOHHYHHAIHLLHEKIHKAHHHHOHEHHE...

correct output
493
HA
HA
HA
HA
...

user output
-6505539032746317152
HJ
HX
HZ
HG
...
Truncated

Test 11

Group: 2, 3

Verdict:

input
WNNFXQNODQFSQVQQPNLQNQNNVVNXHN...

correct output
499
NQ
NQ
NQ
NQ
...

user output
-6363109438946101866
NU
QU
NU
NZ
...
Truncated

Test 12

Group: 2, 3

Verdict:

input
VGAHMMMXMMVXAAMMMOMMMXVMMMYMXT...

correct output
500
MH
MH
MH
MH
...

user output
-6434886614535457125
MG
MJ
HJ
MJ
...
Truncated

Test 13

Group: 2, 3

Verdict:

input
KKKKUUAKKAUKKKKFKKSVKCWKKKCVOJ...

correct output
500
KI
KI
KI
KI
...

user output
-6219835325792604255
KY
IY
KE
IE
...
Truncated

Test 14

Group: 2, 3

Verdict:

input
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVV...

correct output
100
VP
VP
VP
VP
...

user output
-6293312432342454894
VG
VE
PE
VN
...
Truncated

Test 15

Group: 3

Verdict:

input
FKKJJBWTSFCDEKFPOKIPWZSVKHACMC...

correct output
100000
CK
CK
CK
CK
...

user output
(empty)

Test 16

Group: 3

Verdict:

input
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

correct output
0

user output
(empty)

Test 17

Group: 3

Verdict:

input
WVKKVVADNVCVKLVYVVZVKVCTNKVLVV...

correct output
99925
VC
VC
VC
VC
...

user output
(empty)

Test 18

Group: 3

Verdict:

input
BBBBBDNXDZQXBBYBBWBSBTMADXBBVZ...

correct output
99999
BE
BE
BE
BE
...

user output
(empty)

Test 19

Group: 3

Verdict:

input
FBRDPLUMLZMLLLUFUCLEMCMULLZLFL...

correct output
100000
LU
LU
LU
LU
...

user output
(empty)

Test 20

Group: 3

Verdict:

input
UUBUBUTUJSLUVBUXTUUMUXUXTMXUXS...

correct output
100000
UX
UX
UX
UX
...

user output
(empty)

Test 21

Group: 3

Verdict:

input
PPPPPPPPPPEPPPPPPPPPPBOPPPPPPP...

correct output
20000
PB
PB
PB
PB
...

user output
(empty)