제출 #49246

#제출 시각아이디문제언어결과실행 시간메모리
49246rzbtRima (COCI17_rima)C++14
0 / 140
2 ms604 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define MAXN 3000005 typedef long long ll; using namespace std; int trie[MAXN][30]; int n; char s[MAXN]; bool kraj[MAXN]; int cvor=1; int sz; int res=0; int dfs(int t){ //printf(" %d\n",t); int br=0, mx=0; for(int i=0;i<30;i++){ if(trie[t][i]){ int tmp=dfs(trie[t][i]); if(tmp){ br++; mx=max(mx,tmp); } } } res=max(res,br+mx-1); if(kraj[t])return (br?br+mx:1); return 0; } int main() { scanf("%d", &n); for(int i=0;i<n;i++){ scanf("%s",s); sz=strlen(s); reverse(s,s+sz); int tren=0; for(int j=0;j<sz;j++){ if(trie[tren][s[j]-'a']) tren=trie[tren][s[j]-'a']; else{ trie[tren][s[j]-'a']=cvor; cvor++; tren=trie[tren][s[j]-'a']; } } kraj[tren]=true; } dfs(0); printf("%d",res); return 0; }

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

rima.cpp: In function 'int main()':
rima.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
rima.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s",s);
         ~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...