제출 #1060473

#제출 시각아이디문제언어결과실행 시간메모리
1060473belgianbotType Printer (IOI08_printer)C++17
10 / 100
54 ms26580 KiB
#include <bits/stdc++.h> using namespace std; vector<char> ans, letters; vector<vector<pair<int,int>>> adj; void dfs(int curr) { sort(adj[curr].begin(), adj[curr].end()); //if (adj[curr].empty()) ans.push_back('P'); for (auto x : adj[curr]) { ans.push_back(letters[x.second]); dfs(x.second); if (letters[x.second] != 'P') ans.push_back('-'); } } int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<string> words(N); for (int i = 0; i < N; i++) cin >> words[i]; sort(words.begin(), words.end()); int cnt = 1; letters.resize(N * 21 + 1); adj.resize(N * 20 + 1); for (int i = 0; i < N; i++) { int pos = 0; for (int j = 0; j < words[i].size(); j++) { bool exist = false; for (auto x : adj[pos]) { if (letters[x.second] == words[i][j]) { pos = x.second; exist = true; x.first = max(x.first, int(words[i].size()) - j - 1); break; } } if (!exist) { adj[pos].push_back({words[i].size() - j - 1, cnt}); letters[cnt] = words[i][j]; pos = cnt; cnt++; } } adj[pos].push_back({0, cnt}); letters[cnt] = 'P'; cnt++; } dfs(0); int m = ans.size(); for (int i = m-1; ans[i] == '-'; i--) { ans.pop_back(); } m = ans.size(); cout << m << '\n'; for (int i = 0; i < m; i++) cout << ans[i] << '\n'; return 0; }

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

printer.cpp: In function 'int main()':
printer.cpp:30:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   for (int j = 0; j < words[i].size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~~~
#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...