CSES - Datatähti 2024 loppu - Results
Submission details
Task:Sulut
Sender:Username*
Submission time:2024-01-20 15:28:39 +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 s1, 2, 3details
#90.00 s1, 2, 3details
#100.00 s1, 2, 3details
#110.00 s1, 2, 3details
#120.00 s1, 2, 3details
#130.00 s1, 2, 3details
#140.00 s1, 2, 3details
#150.00 s1, 2, 3details
#160.00 s1, 2, 3details
#170.00 s1, 2, 3details
#180.00 s1, 2, 3details
#190.00 s1, 2, 3details
#200.00 s2, 3details
#210.00 s2, 3details
#220.00 s2, 3details
#230.00 s2, 3details
#240.00 s2, 3details
#250.00 s3details
#260.00 s3details
#270.00 s3details
#280.00 s3details
#290.00 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:61:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<char, char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for (int i = 0; i < combs.size(); ++i) {
      |                     ~~^~~~~~~~~~~~~~

Code

#include "bits/stdc++.h"

typedef long long ll;

using namespace std;

int main() {
    string in;
    cin >> in;

    //ll size = in.size();
    //cout << size << endl;

    deque<pair<char, int>> q;
    map<char, int> mp;
    for (char& c : in) {
        if(c)
        mp[c] += 1;
    }
    for (auto a : mp) {
        q.push_back(a);
    }

    vector<pair<char, char>> combs;

    while (!q.empty()) {
        pair<char, int> p = q.front();

        char c = p.first;
        int n = p.second;
        //cout << c << ": " << n << endl;
        /*if(n >= floor(size/2)) {
            max = floor(mp.size()-1);
        }*/
        q.pop_front();
        bool front = false;
        while (n > 0) {
            if(q.empty()) {
                break;
            }
            front = !front;
            auto b = front ? q.front() : q.back();
            int j = b.second;
            //cout << "g  " << b.first << ": " << b.second << endl;
            
            combs.push_back(make_pair(c, b.first));
            n -= 1;
            j -= 1;

            front ? q.pop_front() : q.pop_back();

            if(j >= 0) {
                front ? q.push_front(make_pair(b.first, j)) : q.push_back(make_pair(b.first, j));
            }
            if(q.empty()) {
                break;
            }
        }
    }
    cout << (combs.size()) << endl;
    for (int i = 0; i < combs.size(); ++i) {
        cout << combs[i].first << combs[i].second << endl;
    }
    //cout << max << endl;
    return 0;
}

Test details

Test 1

Group: 1, 2, 3

Verdict:

input
2 0

correct output
()
()

user output
0

Test 2

Group: 1, 2, 3

Verdict:

input
4 0

correct output
()()
()()

user output
0

Test 3

Group: 1, 2, 3

Verdict:

input
4 2

correct output
()()
(())

user output
0

Test 4

Group: 1, 2, 3

Verdict:

input
6 0

correct output
()()()
()()()

user output
0

Test 5

Group: 1, 2, 3

Verdict:

input
6 2

correct output
()()()
()(())

user output
0

Test 6

Group: 1, 2, 3

Verdict:

input
6 4

correct output
()()()
(()())

user output
0

Test 7

Group: 1, 2, 3

Verdict:

input
8 0

correct output
()()()()
()()()()

user output
0

Test 8

Group: 1, 2, 3

Verdict:

input
8 2

correct output
()()()()
()()(())

user output
0

Test 9

Group: 1, 2, 3

Verdict:

input
8 4

correct output
()()()()
()(()())

user output
0

Test 10

Group: 1, 2, 3

Verdict:

input
8 6

correct output
()()()()
(()()())

user output
0

Test 11

Group: 1, 2, 3

Verdict:

input
10 0

correct output
()()()()()
()()()()()

user output
1
01

Test 12

Group: 1, 2, 3

Verdict:

input
10 2

correct output
()()()()()
()()()(())

user output
1
01

Test 13

Group: 1, 2, 3

Verdict:

input
10 4

correct output
()()()()()
()()(()())

user output
1
01

Test 14

Group: 1, 2, 3

Verdict:

input
10 6

correct output
()()()()()
()(()()())

user output
1
01

Test 15

Group: 1, 2, 3

Verdict:

input
10 8

correct output
()()()()()
(()()()())

user output
1
01

Test 16

Group: 1, 2, 3

Verdict:

input
4 1

correct output
IMPOSSIBLE

user output
0

Test 17

Group: 1, 2, 3

Verdict:

input
4 4

correct output
IMPOSSIBLE

user output
0

Test 18

Group: 1, 2, 3

Verdict:

input
5 1

correct output
IMPOSSIBLE

user output
0

Test 19

Group: 1, 2, 3

Verdict:

input
5 2

correct output
IMPOSSIBLE

user output
0

Test 20

Group: 2, 3

Verdict:

input
100 0

correct output
()()()()()()()()()()()()()()()...

user output
2
01
01

Test 21

Group: 2, 3

Verdict:

input
100 10

correct output
()()()()()()()()()()()()()()()...

user output
2
01
01

Test 22

Group: 2, 3

Verdict:

input
100 42

correct output
()()()()()()()()()()()()()()()...

user output
2
01
01

Test 23

Group: 2, 3

Verdict:

input
100 80

correct output
()()()()()()()()()()()()()()()...

user output
2
01
01

Test 24

Group: 2, 3

Verdict:

input
100 98

correct output
()()()()()()()()()()()()()()()...

user output
2
01
01

Test 25

Group: 3

Verdict:

input
1000000 0

correct output
()()()()()()()()()()()()()()()...

user output
2
01
01

Test 26

Group: 3

Verdict:

input
1000000 42

correct output
()()()()()()()()()()()()()()()...

user output
2
01
01

Test 27

Group: 3

Verdict:

input
1000000 4242

correct output
()()()()()()()()()()()()()()()...

user output
2
01
01

Test 28

Group: 3

Verdict:

input
1000000 424242

correct output
()()()()()()()()()()()()()()()...

user output
2
01
01

Test 29

Group: 3

Verdict:

input
1000000 999998

correct output
()()()()()()()()()()()()()()()...

user output
2
01
01