Task: | Text Alignment |
Sender: | arnxxau |
Submission time: | 2024-11-27 17:32:02 +0200 |
Language: | C++ (C++20) |
Status: | READY |
Result: | RUNTIME ERROR |
test | verdict | time | |
---|---|---|---|
#1 | RUNTIME ERROR | 0.00 s | details |
#2 | RUNTIME ERROR | 0.00 s | details |
#3 | RUNTIME ERROR | 0.00 s | details |
#4 | RUNTIME ERROR | 0.00 s | details |
#5 | RUNTIME ERROR | 0.00 s | details |
#6 | WRONG ANSWER | 0.00 s | details |
#7 | WRONG ANSWER | 0.00 s | details |
#8 | WRONG ANSWER | 0.00 s | details |
#9 | WRONG ANSWER | 0.00 s | details |
#10 | WRONG ANSWER | 0.00 s | details |
#11 | WRONG ANSWER | 0.00 s | details |
#12 | WRONG ANSWER | 0.00 s | details |
#13 | WRONG ANSWER | 0.00 s | details |
Compiler report
input/code.cpp: In function 'std::vector<std::__cxx11::basic_string<char> > fullJustify(std::vector<std::__cxx11::basic_string<char> >&, int)': input/code.cpp:13:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare] 13 | for (i = 0; i < a.size(); i = j) { | ~~^~~~~~~~~~ input/code.cpp:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare] 15 | for (j = i; j < a.size() && width + a[j].size() + j - i <= b; j++) { | ~~^~~~~~~~~~ input/code.cpp:15:65: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare] 15 | for (j = i; j < a.size() && width +...
Code
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; #include <climits> #include <string> using ll = long long int; vector<string> fullJustify(vector<string> &a, int b) { vector<string> result; int i, j; for (i = 0; i < a.size(); i = j) { int width = 0; for (j = i; j < a.size() && width + a[j].size() + j - i <= b; j++) { width += a[j].size(); } int space = 1; int extra = 0; if (j - i != 1 && j != a.size()) { space = (b - width) / (j - i - 1); extra = (b - width) % (j - i - 1); } string line(a[i]); for (int k = i + 1; k < j; k++) { line += string(space, ' '); if (extra-- > 0) { line += " "; } line += a[k]; } int x = line.size(); line += string(b - x, ' '); result.push_back(line); } return result; } int main() { string s; vector<string> v; while (cin >> s) { v.push_back(s); } vector<string> ans = fullJustify(v, v.size()); for (int i = 0; i < ans.size(); i++) cout << ans[i] << endl; }
Test details
Test 1
Verdict: RUNTIME ERROR
input |
---|
zsyadhzdg ke irkyowki nflwfanr... |
correct output |
---|
zsyadhzdg ... |
user output |
---|
(empty) |
Error:
terminate called after throwing an instance of 'std::length_error' what(): basic_string...
Test 2
Verdict: RUNTIME ERROR
input |
---|
eayoylmki efsqdhm qqvnrd npesu... |
correct output |
---|
eayoylmki ... |
user output |
---|
(empty) |
Error:
terminate called after throwing an instance of 'std::length_error' what(): basic_string...
Test 3
Verdict: RUNTIME ERROR
input |
---|
bsvhdnoxlxad f bclsa llq hjrmp... |
correct output |
---|
bsvhdnoxlxad ... |
user output |
---|
(empty) |
Error:
terminate called after throwing an instance of 'std::length_error' what(): basic_string...
Test 4
Verdict: RUNTIME ERROR
input |
---|
xoezwspspfdzfasgxlqu f wjzpekp... |
correct output |
---|
xoezwspspfdzfasgxlqu ... |
user output |
---|
(empty) |
Error:
terminate called after throwing an instance of 'std::length_error' what(): basic_string...
Test 5
Verdict: RUNTIME ERROR
input |
---|
bwvfj zmcpktjnmhzevcqtvlg twch... |
correct output |
---|
bwvfj ... |
user output |
---|
(empty) |
Error:
terminate called after throwing an instance of 'std::length_error' what(): basic_string...
Test 6
Verdict: WRONG ANSWER
input |
---|
yifvbbjczpcnpknimq lttkngpeqsz... |
correct output |
---|
yifvbbjczpcnpknimq ... |
user output |
---|
yifvbbjczpcnpknimq lttkngpeqszxvmkrw vlbrsdujtqsloodcy kffvs zogurtpssu wjvghk ... Truncated |
Test 7
Verdict: WRONG ANSWER
input |
---|
fu lzslzio ncbkga nrwuijkbrh x... |
correct output |
---|
fu ... |
user output |
---|
fu lzslzio ncbkga nrwuijkbrh xsfilyygatpgyw eouxy lnk jrfmcfmmpjymjjhv tyieod ... Truncated |
Test 8
Verdict: WRONG ANSWER
input |
---|
azgwjnvgkapltkknwm odostksvqal... |
correct output |
---|
azgwjnvgkapltkknwm ... |
user output |
---|
azgwjnvgkapltkknwm odostksvqaljhmzwibf bhzrdh eblfnky nirzdaijhjotryhidl hru ... Truncated |
Test 9
Verdict: WRONG ANSWER
input |
---|
j mmadidafwkd dckim iwjy bzsso... |
correct output |
---|
j ... |
user output |
---|
j mmadidafwkd dckim iwjy bzssodxdryoosyk sovqmtyjuvzce nb mqfwyzzergpwuxbtpjb eplmpm ... Truncated |
Test 10
Verdict: WRONG ANSWER
input |
---|
barm sykc faxmvycwxs cnxuwpetq... |
correct output |
---|
barm ... |
user output |
---|
barm sykc faxmvycwxs cnxuwp... Truncated |
Test 11
Verdict: WRONG ANSWER
input |
---|
ltwg ns j axhacysdjhrpzymwxae ... |
correct output |
---|
ltwg ... |
user output |
---|
ltwg ns j axhacysdjhrpzymwx... Truncated |
Test 12
Verdict: WRONG ANSWER
input |
---|
pgwvxzeztltppuuq siarhxbs mjmr... |
correct output |
---|
pgwvxzeztltppuuq ... |
user output |
---|
pgwvxzeztltppuuq siarhxbs mj... Truncated |
Test 13
Verdict: WRONG ANSWER
input |
---|
xurwjadifyf iijoofrunig zadrff... |
correct output |
---|
xurwjadifyf ... |
user output |
---|
xurwjadifyf iijoofrunig zadrf... Truncated |