Submission #432989

# Submission time Handle Problem Language Result Execution time Memory
432989 2021-06-18T17:08:32 Z SAAD Type Printer (IOI08_printer) C++17
0 / 100
611 ms 3500 KB
#define F first
#define S second
#define rep(i,a,b) for(int i=a;!(a==b&&i!=b)&&((i<=b&&b>=a)||(i>=b&&a>=b));i+=(a<=b?1:-1))
#define pb push_back
#define Fbitl __builtin_ffs
#define bit1 __builtin_popcount
//#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
//#include "memory.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
int mx[200];
int main(){
    priority_queue <pair<pair<int,int>, string>> q;
    int n;
    cin >> n;
    string s;
    vector <string> x;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        mx[s[0]] = max(mx[s[0]],(int)s.length());
        x.push_back(s);
    }
    for (auto i : x)
        q.push({{-(mx[i[0]]),-i.length()},i});
    string now = "";
    while (!q.empty()) {
        s = q.top().second;
        if (now == "") {
            for (auto i : s) {
                cout << i << endl;
                now += i;
            }
            cout << "P\n";
        }
        else {
            while (now.length()&&(now.length() > s.length() || (s.length()>=now.length()&&s.substr(0,now.length())!=now) )) {
                now.pop_back();
                cout << '-' << endl;
            }
            for (int i = now.length(); i < s.length(); i++) {
                cout << s[i] << endl;
                now += s[i];
            }
            cout << 'P' << endl;
        }
        q.pop();
    }
    return 0;
}

Compilation message

printer.cpp: In function 'int main()':
printer.cpp:37:16: warning: array subscript has type 'char' [-Wchar-subscripts]
   37 |         mx[s[0]] = max(mx[s[0]],(int)s.length());
      |                ^
printer.cpp:37:31: warning: array subscript has type 'char' [-Wchar-subscripts]
   37 |         mx[s[0]] = max(mx[s[0]],(int)s.length());
      |                               ^
printer.cpp:41:27: warning: array subscript has type 'char' [-Wchar-subscripts]
   41 |         q.push({{-(mx[i[0]]),-i.length()},i});
      |                           ^
printer.cpp:57:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |             for (int i = now.length(); i < s.length(); i++) {
      |                                        ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Expected integer, but "t" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Expected integer, but "n" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Expected integer, but "i" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Expected integer, but "t" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 204 KB Expected integer, but "w" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 440 KB Expected integer, but "v" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 892 KB Expected integer, but "z" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 247 ms 1604 KB Expected integer, but "z" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 611 ms 3192 KB Expected integer, but "z" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 521 ms 3500 KB Expected integer, but "z" found
2 Halted 0 ms 0 KB -