제출 #96807

#제출 시각아이디문제언어결과실행 시간메모리
96807tieunhiRima (COCI17_rima)C++14
0 / 140
1216 ms263168 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 add(string s) { int p = 1; FOR(i, 0, s.size()-1) { int c = s[i] - 'a'; if (t[p].child[c] == 0) t[p].child[c] = ++tt; p = t[p].child[c]; } t[p].cnt++; } 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); //freopen("INP.TXT", "r", stdin); //freopen("OUT.TXT", "w", stdout); cin >> n; FOR(i, 1, n) { string s; cin >> s; reverse(s.begin(), s.end()); add(s); } DFS(1); cout <<*max_element(dp+1, dp+tt+1); }

컴파일 시 표준 에러 (stderr) 메시지

rima.cpp: In function 'void add(std::__cxx11::string)':
rima.cpp:2:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define FOR(i, u, v) for (int i = u; i <= v; i++)
rima.cpp:33:9:
     FOR(i, 0, s.size()-1)
         ~~~~~~~~~~~~~~~~                
rima.cpp:33:5: note: in expansion of macro 'FOR'
     FOR(i, 0, s.size()-1)
     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...