CSES - Aalto Competitive Programming 2024 - wk12 - Wed - Results
Submission details
Task:Text Alignment
Sender:bubu2006
Submission time:2024-11-27 17:25:17 +0200
Language:C++ (C++20)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.00 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails
#10ACCEPTED0.00 sdetails
#11ACCEPTED0.00 sdetails
#12ACCEPTED0.00 sdetails
#13ACCEPTED0.00 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:56:20: warning: statement has no effect [-Wunused-value]
   56 | #define debug(...) 42
      |                    ^~
input/code.cpp:74:5: note: in expansion of macro 'debug'
   74 |     debug(v);
      |     ^~~~~

Code

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
string to_string(string s) {
return '"' + s + '"';
}
string to_string(const char* s) {
return to_string((string) s);
}
string to_string(bool b) {
return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
bool first = true;
string res = "{";
for (const auto &x : v) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(x);
}
res += "}";
return res;
}
void debug_out() {
cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << " " << to_string(H);
debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit); // RTE if input wrong datatype
string s;
getline(cin, s);
stringstream st(s);
vector<string> v;
string cur;
while (st >> cur) {
if (sz(cur)) v.push_back(cur);
}
debug(v);
int curlen = 0;
vector<string> curv;
for (int i = 0; i < sz(v); i++) {
curlen += sz(v[i]) + 1;
curv.push_back(v[i]);
if (i == sz(v) - 1 || curlen + sz(v[i + 1]) + 1 >= 50 || (sz(curv) != 1 && i == sz(v) - 3)) {
int need = 50 - (curlen - 1);
// debug(need);
curv.back() = string(need, ' ') + curv.back();
for (int j = 0; j < sz(curv); j++) {
cout << curv[j];
if (j != sz(curv) - 1) cout << ' ';
}
cout << '\n';
curlen = 0;
curv.clear();
}
}
}

Test details

Test 1

Verdict: ACCEPTED

input
zsyadhzdg ke irkyowki nflwfanr...

correct output
zsyadhzdg                     ...

user output
zsyadhzdg                     ...
Truncated

Test 2

Verdict: ACCEPTED

input
eayoylmki efsqdhm qqvnrd npesu...

correct output
eayoylmki                     ...

user output
eayoylmki efsqdhm qqvnrd      ...
Truncated

Test 3

Verdict: ACCEPTED

input
bsvhdnoxlxad f bclsa llq hjrmp...

correct output
bsvhdnoxlxad                  ...

user output
bsvhdnoxlxad f bclsa llq      ...
Truncated

Test 4

Verdict: ACCEPTED

input
xoezwspspfdzfasgxlqu f wjzpekp...

correct output
xoezwspspfdzfasgxlqu          ...

user output
xoezwspspfdzfasgxlqu f wjzpekp...
Truncated

Test 5

Verdict: ACCEPTED

input
bwvfj zmcpktjnmhzevcqtvlg twch...

correct output
bwvfj                         ...

user output
bwvfj zmcpktjnmhzevcqtvlg twch...
Truncated

Test 6

Verdict: ACCEPTED

input
yifvbbjczpcnpknimq lttkngpeqsz...

correct output
yifvbbjczpcnpknimq            ...

user output
yifvbbjczpcnpknimq            ...
Truncated

Test 7

Verdict: ACCEPTED

input
fu lzslzio ncbkga nrwuijkbrh x...

correct output
fu                            ...

user output
fu lzslzio ncbkga nrwuijkbrh  ...
Truncated

Test 8

Verdict: ACCEPTED

input
azgwjnvgkapltkknwm odostksvqal...

correct output
azgwjnvgkapltkknwm            ...

user output
azgwjnvgkapltkknwm odostksvqal...
Truncated

Test 9

Verdict: ACCEPTED

input
j mmadidafwkd dckim iwjy bzsso...

correct output
j                             ...

user output
j mmadidafwkd dckim iwjy      ...
Truncated

Test 10

Verdict: ACCEPTED

input
barm sykc faxmvycwxs cnxuwpetq...

correct output
barm                          ...

user output
barm sykc faxmvycwxs          ...
Truncated

Test 11

Verdict: ACCEPTED

input
ltwg ns j axhacysdjhrpzymwxae ...

correct output
ltwg                          ...

user output
ltwg ns j axhacysdjhrpzymwxae ...
Truncated

Test 12

Verdict: ACCEPTED

input
pgwvxzeztltppuuq siarhxbs mjmr...

correct output
pgwvxzeztltppuuq              ...

user output
pgwvxzeztltppuuq siarhxbs     ...
Truncated

Test 13

Verdict: ACCEPTED

input
xurwjadifyf iijoofrunig zadrff...

correct output
xurwjadifyf                   ...

user output
xurwjadifyf iijoofrunig       ...
Truncated