CSES - Datatähti 2022 loppu - Results
Submission details
Task:Kanava
Sender:hltk
Submission time:2022-01-22 16:35:45 +0200
Language:C++ (C++17)
Status:READY
Result:35
Feedback
groupverdictscore
#1ACCEPTED35
Test results
testverdicttimescore
#1ACCEPTED0.01 s35details

Code

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  if (t == 1) {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
      string s;
      cin >> s;
      string r = "_";
      for (char c : s) {
        int b = c - 'a';
        for (int j = 0; j < 5; ++j) {
          r += '0' + !!(b & (1 << j));
        }
      }
      for (int k = 0; k < 4; ++k) {
        if (r.size() > 2 && r.back() == '0') {
          r.pop_back();
        }
      }
      cout << r << endl;
    }
  } else {
    string s;
    cin >> s;
    s += "_";
    string c;
    cout << count(s.begin(), s.end(), '_') << endl;
    for (char u : s) {
      if (u == '_') {
        string k;
        for (int i = 0; i < (int) c.size(); i += 5) {
          k.push_back(0);
          for (int j = 0; j < 5; ++j) {
            if (i + j < (int) c.size() && c[i + j] == '1') {
              k.back() += 1 << j;
            }
          }
          k.back() += 'a';
        }
        cout << k << endl;
        c.clear();
      } else {
        c += u;
      }
    }
  }
}

Test details

Test 1

Verdict: ACCEPTED

input
1
520
cbmcsyv
uvub
yh
...

correct output
(empty)

user output
965
ygk
rgzpwpac
ffczhfplny
nwuzdjdj
...
Truncated