Submission #217166

# Submission time Handle Problem Language Result Execution time Memory
217166 2020-03-29T07:12:49 Z tatyam Type Printer (IOI08_printer) C++17
20 / 100
45 ms 2452 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];
    sort(all(a), greater<string>());
    each(i, a) rep(j, i.size()) i[j] ^= t[j];
    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];
                ^~~
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];
                ^~~
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 6 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 7 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 1296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 2452 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 2324 KB Output isn't correct
2 Halted 0 ms 0 KB -