제출 #159894

#제출 시각아이디문제언어결과실행 시간메모리
159894MetBSavez (COCI15_savez)C++14
0 / 120
264 ms65540 KiB
#include <iostream> #include <vector> #include <stdio.h> #include <algorithm> #include <map> #include <fstream> #include <set> #include <cstring> #include <cassert> #include <cstdlib> #include <cmath> #include <queue> #define N 2000000 using namespace std; typedef long long ll; const ll INF = 1e15, MOD = 1e9 + 7, MOD2 = 1e6 + 3; struct Trie { struct Node { int d; map < pair <char, char>, Node* > to; bool leaf; Node () : d (0), leaf (false) {} }; Node* root = new Node (); int add (string s) { string t = s; reverse (t.begin(), t.end()); int d = 1; Node* x = root; for (int i = 0; i < s.length (); i++) { if (x -> to.find ({s[i], t[i]}) == x -> to.end ()) { x -> to[{s[i], t[i]}] = new Node (); } x = x -> to[{s[i], t[i]}]; if (x -> leaf) d = max (d, x -> d + 1); } x -> leaf = true; x -> d = d; return d; } } t; bool comp (const string& a, const string& b) { return a.length () < b.length (); } int n; string s[N]; int main () { cin >> n; for (int i = 0; i < n; i++) { cin >> s[i]; } sort (s, s + n, comp); int ans = 0; for (int i = 0; i < n; i++) { ans = max (ans, t.add (s[i])); } cout << ans; }

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

savez.cpp: In member function 'int Trie::add(std::__cxx11::string)':
savez.cpp:40:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < s.length (); i++) {
                   ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...