답안 #1023867

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1023867 2024-07-15T08:07:33 Z MrAndria DEL13 (info1cup18_del13) C++14
0 / 100
8 ms 1496 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,v3,v1;
int main(){
    cin>>t;
    while(t--){
        cin>>n>>q;
        for(int i=1;i<=q;i++){
            cin>>a[i];
        }
        v2.clear();
        v1.clear();
        v3.clear();
        v.clear();
        a[q+1]=n+1;
        b1=0;
        for(int i=1;i<=q+1;i++){
            v.pb(a[i]-a[i-1]-1);
            // cout<<a[i]-a[i-1]-1<<" ";
        }
        // cout<<endl;
        l=0;
        v2.pb(l);
        for(int i=0;i<v.size();i++){
            v[i]-=l;
            if(v[i]<0){
                b1=1;
                break;
            }
            if(v[i]==0){
                l=0;
                v1.pb(v[i]);
            }else{
                if(v[i]%2==1){
                    l=1;
                    v1.pb(v[i]-1);
                }else{
                    if(l==2 or l==1){
                        l=0;

                        v1.pb(v[i]);
                    }else{
                        l=2;
                        v1.pb(v[i]-2);
                    }
                }
            }
            v2.pb(l);
        }
        
        if(l!=0 or b1){
            cout<<-1<<endl;
            continue;
        }
        
        for(int i=0;i<v2.size();i++){
            for(int j=0;j<(v1[i])/2;j++){
                v3.pb((a[i]+a[i+1])/2);

            }
            if(i!=v2.size()-1){
                for(int j=0;j<(v2[i+1]);j++){
                    v3.pb(a[i+1]);
                }
            }
        }
        if(v3.size()>(n-q)/2)assert(0);
        cout<<v3.size()<<endl;
        for(int i=0;i<v3.size();i++){
            cout<<v3[i]<<" ";
        }
        cout<<endl;
    }
}

Compilation message

del13.cpp: In function 'int main()':
del13.cpp:30:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         for(int i=0;i<v.size();i++){
      |                     ~^~~~~~~~~
del13.cpp:62:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for(int i=0;i<v2.size();i++){
      |                     ~^~~~~~~~~~
del13.cpp:67:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |             if(i!=v2.size()-1){
      |                ~^~~~~~~~~~~~~
del13.cpp:73:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   73 |         if(v3.size()>(n-q)/2)assert(0);
      |            ~~~~~~~~~^~~~~~~~
del13.cpp:75:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |         for(int i=0;i<v3.size();i++){
      |                     ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 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 604 KB Execution killed with signal 6
2 Runtime error 1 ms 604 KB Execution killed with signal 6
3 Runtime error 1 ms 604 KB Execution killed with signal 6
4 Runtime error 0 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 2 ms 708 KB Execution killed with signal 6
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Runtime error 1 ms 604 KB Execution killed with signal 6
3 Runtime error 1 ms 604 KB Execution killed with signal 6
4 Runtime error 0 ms 604 KB Execution killed with signal 6
5 Runtime error 1 ms 604 KB Execution killed with signal 6
6 Incorrect 1 ms 348 KB Output isn't correct
7 Incorrect 1 ms 348 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Runtime error 1 ms 604 KB Execution killed with signal 6
3 Runtime error 1 ms 604 KB Execution killed with signal 6
4 Runtime error 0 ms 604 KB Execution killed with signal 6
5 Runtime error 1 ms 604 KB Execution killed with signal 6
6 Incorrect 1 ms 348 KB Output isn't correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Runtime error 2 ms 860 KB Execution killed with signal 6
9 Runtime error 6 ms 1080 KB Execution killed with signal 6
10 Incorrect 8 ms 1024 KB Output isn't correct
11 Runtime error 4 ms 1496 KB Execution killed with signal 6