답안 #1020945

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1020945 2024-07-12T11:55:59 Z MrAndria DEL13 (info1cup18_del13) C++17
0 / 100
2 ms 860 KB
#include <bits/stdc++.h>
using namespace std;
#define ff first;
#define ss second
#define pb push_back
//#define int long long
int t,n,q,b1,l;
int a[200005];
vector <int> v,v2;
int main(){
    cin>>t;
    while(t--){
        cin>>n>>q;
        for(int i=1;i<=q;i++){
            cin>>a[i];
        }
        v2.clear();
        v.clear();
        a[q+1]=n+1;

        for(int i=1;i<=q+1;i++){
            if(a[i]-a[i-1]-1==0){
                v.pb(0);
            }else{
                if((a[i]-a[i-1]-1)%2==0){
                    v.pb(2);
                }else{
                    v.pb(1);
                }
            }
        }
        for(int i=1;i<v.size();i++){
            v[i]-=v[i-1];

        }
        if(v.back()!=0){
            cout<<-1<<endl;
            continue;
        }
        for(int i=1;i<=q+1;i++){
            if(a[i]-a[i-1]-1==0){
            }else{
                if((a[i]-a[i-1]-1)%2==0){
                    for(int j=1;j<=(a[i]-a[i-1]-3)/2;j++){
                        v2.pb((a[i]+a[i-1])/2);
                    }
                }else{
                    for(int j=1;j<=(a[i]-a[i-1]-2)/2;j++){
                        // cout<<"YES"<<endl;
                        v2.pb((a[i]+a[i-1])/2);
                    }
                }
            }
        }
        for(int i=1;i<v.size();i++){
            for(int j=1;j<=v[i-1];j++){
                v2.pb(a[i]);
            }
        }
        if(v2.size()!=(n-q)/2){
            assert(0);
        }
        cout<<v2.size()<<endl;
        for(int i=0;i<v2.size();i++){
            cout<<v2[i]<<" ";
        }
        cout<<endl;
        // b1=0;
        // v.clear();
        // l=1;
        // for(int i=1;i<=q;i++){
        //     for(int j=1;j<=a[i]-l;j++){
        //         v.pb(a[i]);
        //     }
        //     l=2*a[i]-l+1;
        //     if(i!=q){
        //         if(a[i+1]<l){
        //             b1=1;
        //             break;
        //         }
        //     }else{
        //         if(l!=n+1){
        //             b1=1;
        //             break;
        //         }
        //     }
        // }
        // if(b1){
        //     cout<<-1<<endl;
        // }else{
        //     cout<<v.size()<<endl;
        //     for(int i=0;i<v.size();i++){
        //         cout<<v[i]<<" ";
        //     }
        //     cout<<endl;
        // }
    }
}

Compilation message

del13.cpp: In function 'int main()':
del13.cpp:32:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for(int i=1;i<v.size();i++){
      |                     ~^~~~~~~~~
del13.cpp:55:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for(int i=1;i<v.size();i++){
      |                     ~^~~~~~~~~
del13.cpp:60:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |         if(v2.size()!=(n-q)/2){
      |            ~~~~~~~~~^~~~~~~~~
del13.cpp:64:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |         for(int i=0;i<v2.size();i++){
      |                     ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Runtime error 1 ms 604 KB Execution killed with signal 6
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Runtime error 1 ms 604 KB Execution killed with signal 6
3 Runtime error 1 ms 600 KB Execution killed with signal 6
4 Runtime error 1 ms 604 KB Execution killed with signal 6
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 6
2 Runtime error 1 ms 604 KB Execution killed with signal 6
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Runtime error 1 ms 604 KB Execution killed with signal 6
3 Runtime error 1 ms 600 KB Execution killed with signal 6
4 Runtime error 1 ms 604 KB Execution killed with signal 6
5 Runtime error 1 ms 604 KB Execution killed with signal 6
6 Runtime error 1 ms 456 KB Execution killed with signal 6
7 Runtime error 1 ms 604 KB Execution killed with signal 6
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Runtime error 1 ms 604 KB Execution killed with signal 6
3 Runtime error 1 ms 600 KB Execution killed with signal 6
4 Runtime error 1 ms 604 KB Execution killed with signal 6
5 Runtime error 1 ms 604 KB Execution killed with signal 6
6 Runtime error 1 ms 456 KB Execution killed with signal 6
7 Runtime error 1 ms 604 KB Execution killed with signal 6
8 Runtime error 2 ms 860 KB Execution killed with signal 6
9 Runtime error 1 ms 604 KB Execution killed with signal 6
10 Runtime error 1 ms 604 KB Execution killed with signal 6
11 Runtime error 1 ms 604 KB Execution killed with signal 6