제출 #1176387

#제출 시각아이디문제언어결과실행 시간메모리
1176387youssefproofType Printer (IOI08_printer)C++20
0 / 100
43 ms328 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define proof ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define tests ll T;cin >> T;while(T--) using namespace std; using namespace __gnu_pbds; #define ordered_set tree< int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> const ll mod = 1e9 + 7; struct Node{ ll cntr; ll nxt[26]; bool endofword = false; }; vector<Node>tri(1); void Insert(string &s) { ll curr = 0; for (int i = 0;i < s.size();i++) { if (!tri[curr].nxt[s[i]-'a']) { tri[curr].nxt[s[i] - 'a'] = tri.size(); tri.emplace_back(); } curr = tri[curr].nxt[s[i]-'a']; tri[curr].cntr++; } tri[curr].endofword = true; } vector<char>ans; void dfs(ll node,ll start = 0) { if (tri[node].endofword) ans.push_back('P'); for (int i = 0;i < 26;i++) { if (tri[node].nxt[(i + start) % 26]) { ans.push_back(((i + start)%26) + 'a'); dfs(tri[node].nxt[(i + start) % 26]); ans.push_back('-'); } } } void solve() { ll n;cin >> n; while (n--) { string s;cin >> s; Insert(s); } vector<char>anss; ll mini = LLONG_MAX; for (int i = 0;i < 26;i++) { dfs(0,i); while (ans.back() == '-') ans.pop_back(); if (ans.size() < mini) { mini = ans.size(); anss = ans; } ans.clear(); } cout << anss.size() << '\n'; for (auto &i : anss) { cout << i << '\n'; } } int main() { proof; #ifndef ONLINE_JUDGE freopen("C:/Users/youss/OneDrive/Desktop/IO/input.txt", "r", stdin); freopen("C:/Users/youss/OneDrive/Desktop/IO/output.txt", "w", stdout); freopen("C:/Users/youss/OneDrive/Desktop/IO/error.txt", "w", stderr); #endif //tests solve(); }

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

printer.cpp: In function 'int main()':
printer.cpp:67:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |     freopen("C:/Users/youss/OneDrive/Desktop/IO/input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:68:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |     freopen("C:/Users/youss/OneDrive/Desktop/IO/output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:69:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |     freopen("C:/Users/youss/OneDrive/Desktop/IO/error.txt", "w", stderr);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...