답안 #1053447

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1053447 2024-08-11T11:59:31 Z Malix Type Printer (IOI08_printer) C++14
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
typedef tuple<int,int,int> tii;
typedef vector<ll> li;
typedef vector<li> lii;
 
#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LSOne(s) ((s)&(-s))
 
ll INF=1e18+10;
int inf=1e9+10;
ll M=1e9+7;

int main() {   
// ios::sync_with_stdio(0);
// cin.tie(0);
freopen("test_input.txt", "r", stdin);
freopen("test_output.txt", "w", stdout);
    int n;cin>>n;
    vector<string> a(n);
    REP(i,0,n)cin>>a[i];
    sort(a.begin(),a.end());
    string s;
    vector<char> ans;
    REP(i,0,n){
        if(s.empty()){
            for(auto u:a[i]){
                ans.PB(u);
                s.PB(u);
            }
            ans.PB('P');
            continue;
        }
        int mn=-1;
        int k=min(s.size(),a[i].size());
        REP(j,0,k){
            if(s[j]!=a[i][j])break;
            mn=j;
        }
        int t=s.size();
        REP(j,mn+1,t){
            ans.PB('-');
            s.pop_back();
        }
        REP(j,mn+1,a[i].size()){
            ans.PB(a[i][j]);
            s.PB(a[i][j]);
        }
    }
    cout<<ans.size()<<"\n";
    for(auto u:ans)cout<<u<<"\n";
}

Compilation message

printer.cpp: In function 'int main()':
printer.cpp:13:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 | #define REP(i,a,b) for(int i=a;i<b;i++)
......
   55 |         REP(j,mn+1,a[i].size()){
      |             ~~~~~~~~~~~~~~~~~~   
printer.cpp:55:9: note: in expansion of macro 'REP'
   55 |         REP(j,mn+1,a[i].size()){
      |         ^~~
printer.cpp:27:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 | freopen("test_input.txt", "r", stdin);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
printer.cpp:28:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 | freopen("test_output.txt", "w", stdout);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -