Submission #217174

#TimeUsernameProblemLanguageResultExecution timeMemory
217174tatyamType Printer (IOI08_printer)C++17
100 / 100
68 ms5684 KiB
#include <bits/stdc++.h> using namespace std; #define name3(a,b,c,d,...) d #define rep1(a) for(int i = 0; i < a; i++) #define rep2(i,a) for(int i = 0; i < a; i++) #define rep3(i,a,b) for(int i = a; i < b; i++) #define rep(...) name3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__) #define each(i,a) for(auto&& i : a) #define all(a) begin(a), end(a) int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<string> a(n); string t; each(i, a){ cin >> i; if(t.size() < i.size()) t = i; } each(i, a) rep(j, i.size()) i[j] ^= t[j] ^ -1; sort(all(a)); each(i, a) rep(j, i.size()) i[j] ^= t[j] ^ -1; string ans; ans += a[0]; ans += 'P'; rep(n - 1){ int at = 0; while(at < a[i].size() && at < a[i + 1].size() && a[i][at] == a[i + 1][at]) at++; rep(j, at, a[i].size()) ans += '-'; rep(j, at, a[i + 1].size()) ans += a[i + 1][j]; ans += 'P'; } cout << ans.size() << '\n'; each(i, ans) cout << i << '\n'; }

Compilation message (stderr)

printer.cpp: In function 'int main()':
printer.cpp:5:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep2(i,a) for(int i = 0; i < a; i++)
                                    ^
printer.cpp:3:28: note: in expansion of macro 'rep2'
 #define name3(a,b,c,d,...) d
                            ^
printer.cpp:7:18: note: in expansion of macro 'name3'
 #define rep(...) name3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
                  ^~~~~
printer.cpp:22:16: note: in expansion of macro 'rep'
     each(i, a) rep(j, i.size()) i[j] ^= t[j] ^ -1;
                ^~~
printer.cpp:5:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep2(i,a) for(int i = 0; i < a; i++)
                                    ^
printer.cpp:3:28: note: in expansion of macro 'rep2'
 #define name3(a,b,c,d,...) d
                            ^
printer.cpp:7:18: note: in expansion of macro 'name3'
 #define rep(...) name3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
                  ^~~~~
printer.cpp:24:16: note: in expansion of macro 'rep'
     each(i, a) rep(j, i.size()) i[j] ^= t[j] ^ -1;
                ^~~
printer.cpp:30:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(at < a[i].size() && at < a[i + 1].size() && a[i][at] == a[i + 1][at]) at++;
               ~~~^~~~~~~~~~~~~
printer.cpp:30:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(at < a[i].size() && at < a[i + 1].size() && a[i][at] == a[i + 1][at]) at++;
                                   ~~~^~~~~~~~~~~~~~~~~
printer.cpp:6:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep3(i,a,b) for(int i = a; i < b; i++)
                                      ^
printer.cpp:3:28: note: in expansion of macro 'rep3'
 #define name3(a,b,c,d,...) d
                            ^
printer.cpp:7:18: note: in expansion of macro 'name3'
 #define rep(...) name3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
                  ^~~~~
printer.cpp:31:9: note: in expansion of macro 'rep'
         rep(j, at, a[i].size()) ans += '-';
         ^~~
printer.cpp:6:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep3(i,a,b) for(int i = a; i < b; i++)
                                      ^
printer.cpp:3:28: note: in expansion of macro 'rep3'
 #define name3(a,b,c,d,...) d
                            ^
printer.cpp:7:18: note: in expansion of macro 'name3'
 #define rep(...) name3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
                  ^~~~~
printer.cpp:32:9: note: in expansion of macro 'rep'
         rep(j, at, a[i + 1].size()) ans += a[i + 1][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...