Submission #96809

#TimeUsernameProblemLanguageResultExecution timeMemory
96809tieunhiRima (COCI17_rima)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define FOR(i, u, v) for (int i = u; i <= v; i++) #define FORD(i, v, u) for (int i = v; i >= u; i--) #define ll long long #define pii pair<int, int> #define PB push_back #define mp make_pair #define F first #define S second #define N 3000005 #define BASE 37 #define mod 1000000007 #define mid (r + l)/2 using namespace std; int n, dp[N]; struct node { int child[26], cnt; node() { FOR(i, 0, 25) child[i] = 0; cnt = 0; } }t[N]; int tt = 1; void DFS(int u) { int cnt1 = 0, vmax = 0; FOR(c, 0, 25) { if (t[u].child[c] == 0) continue; int v = t[u].child[c]; DFS(v); if (t[v].cnt == 0) continue; else if (t[v].cnt == 1) { cnt1++; vmax = max(vmax, dp[v]); } else dp[u] += (dp[v] + t[v].cnt); } dp[u] += (cnt1 + vmax); } int main() { ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); //freopen("INP.TXT", "r", stdin); //freopen("OUT.TXT", "w", stdout); cin >> n; FOR(i, 1, n) { cin >> s; int p = 1; FORD(i, s.size()-1, 0) { int c = s[i] - 'a'; if (t[p].child[c] == 0) t[p].child[c] = ++tt; p = t[p].child[c]; } t[p].cnt++; } DFS(1); cout <<*max_element(dp+1, dp+tt+1); }

Compilation message (stderr)

rima.cpp: In function 'int main()':
rima.cpp:58:16: error: 's' was not declared in this scope
         cin >> s;
                ^