Skip to content
Snippets Groups Projects
Commit bc1bc9b8 authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

lib: Lepší parsování vstupu

parent f2e09afc
No related branches found
No related tags found
No related merge requests found
......@@ -154,6 +154,8 @@ namespace lib
{
int mistakes_int;
assert(scanf("%d %d\n", &n, &mistakes_int) == 2);
assert(n>0);
assert(mistakes_int == 0 || mistakes_int == 1);
mistakes = mistakes_int;
assert(scanf("%m[^\n]\n", &verdict) == 1);
......@@ -164,6 +166,7 @@ namespace lib
assert(scanf("%m[^\n]", &out_data) == 1);
assert(strlen(out_data) == 2*n);
out = vector<bool>(2*n);
fo(i, 2*n) assert(out_data[i] == '0' || out_data[i] == '1');
fo(i, 2*n) out[i] = out_data[i] - '0';
delete [] out_data;
......@@ -171,6 +174,11 @@ namespace lib
input = vector<int>(2*n);
assert(fread(input.data(), sizeof(int), 2*n, stdin) == 2*n);
fo(i, 2*n) assert(input[i] >= 0 && input[i] < 2*n);
vector<int> num_used(n);
fo(i, 2*n) num_used[input[i]]++;
fo(i, n) assert(num_used[i] == 2);
}
}
void log_data(const char * key, const char *fmt, ...)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment