# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
321259 | 2020-11-11T18:26:37 Z | vukasinbabic06 | Type Printer (IOI08_printer) | C++14 | 1 ms | 384 KB |
#include <bits/stdc++.h> #define inc(a,b,c) for(int a(b);a<=(c);a++) #define dec(a,b,c) for(int a(b);a>=(c);a--) using namespace std; typedef long long ll; typedef pair<int, int> P; const int MAX_N = 25005; const int MOD = 100003; const int INF = 0x3f3f3f3f; struct Word{ char c[25]; int id; }; int N, k, ans; int len[MAX_N], val[MAX_N]; Word s[MAX_N]; // compare by first the length of common prefix with the longest word and then lexicographically bool comp(Word a, Word b){ return val[a.id] == val[b.id] ? lexicographical_compare(a.c + 1, a.c + len[a.id] + 1, b.c + 1, b.c + len[b.id] + 1) : val[a.id] < val[b.id]; } int main(){ freopen("type.in", "r", stdin); freopen("type.out", "w", stdout); scanf("%d", &N); inc(i, 1, N) scanf("%s", s[i].c + 1), s[i].id = i; inc(i, 1, N){ len[i] = strlen(s[i].c + 1); if(len[i] > len[k]) k = i; } inc(i, 1, N) inc(j, 1, len[i]) if(s[i].c[j] == s[k].c[j]) val[i]++; else break; sort(s + 1, s + N + 1, comp); inc(i, 1, N){ int temp = 0; while(temp < min(len[s[i - 1].id], len[s[i].id]) && s[i - 1].c[temp + 1] == s[i].c[temp + 1]) temp++; inc(j, 1, len[s[i - 1].id] - temp) ans++; inc(j, temp + 1, len[s[i].id]) ans++; ans++; } printf("%d\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 364 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 364 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 364 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 364 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |