Submission #217174

# Submission time Handle Problem Language Result Execution time Memory
217174 2020-03-29T07:19:04 Z tatyam Type Printer (IOI08_printer) C++17
100 / 100
68 ms 5684 KB
#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

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 time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 640 KB Output is correct
2 Correct 21 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1168 KB Output is correct
2 Correct 14 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 2324 KB Output is correct
2 Correct 57 ms 4784 KB Output is correct
3 Correct 42 ms 3860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 2068 KB Output is correct
2 Correct 68 ms 5684 KB Output is correct
3 Correct 44 ms 4116 KB Output is correct
4 Correct 63 ms 5424 KB Output is correct