답안 #762510

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
762510 2023-06-21T12:49:30 Z Trunkty DEL13 (info1cup18_del13) C++14
0 / 100
10 ms 2008 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll

int t;
int arr[100005];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> t;
    for(int e=1;e<=t;e++){
        int n,q;
        cin >> n >> q;
        vector<int> v,ans;
        for(int i=1;i<=q;i++){
            cin >> arr[i];
            v.push_back(arr[i]-arr[i-1]-1LL);
        }
        arr[q+1] = n+1;
        v.push_back(n-arr[q]);
        for(int i=0;i<v.size();i++){
            int mid = (arr[i]+arr[i+1])/2;
            for(int k=1;k<=(v[i]-1)/2;k++){
                ans.push_back(mid);
            }
        }
        for(int i=0;i<v.size();i++){
            if(v[i]%2){
                v[i] = 1;
            }
            else if(v[i]!=0){
                v[i] = 2;
            }
        }
        bool bad = false;
        for(int i=0;i<v.size()-1;i++){
            if(v[i]>v[i+1]){
                bad = true;
            }
            else if(v[i]==2){
                v[i] -= 2;
                v[i+1] -= 2;
                ans.push_back(arr[i+1]);
                ans.push_back(arr[i+1]);
            }
            else if(v[i]==1){
                v[i]--;
                v[i+1]--;
                ans.push_back(arr[i+1]);
            }
        }
        if(bad){
            cout << -1 << "\n";
        }
        else{
            cout << ans.size() << "\n";
            for(int i:ans){
                cout << i << " ";
            }
            cout << "\n";
        }
    }
    return 0;
}

Compilation message

del13.cpp: In function 'int main()':
del13.cpp:23:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for(int i=0;i<v.size();i++){
      |                     ~^~~~~~~~~
del13.cpp:29:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for(int i=0;i<v.size();i++){
      |                     ~^~~~~~~~~
del13.cpp:38:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for(int i=0;i<v.size()-1;i++){
      |                     ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Incorrect 1 ms 340 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Incorrect 4 ms 344 KB Output isn't correct
4 Incorrect 3 ms 340 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 596 KB Output isn't correct
2 Incorrect 2 ms 1212 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Incorrect 4 ms 344 KB Output isn't correct
4 Incorrect 3 ms 340 KB Output isn't correct
5 Incorrect 1 ms 340 KB Output isn't correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Incorrect 1 ms 340 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Incorrect 4 ms 344 KB Output isn't correct
4 Incorrect 3 ms 340 KB Output isn't correct
5 Incorrect 1 ms 340 KB Output isn't correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Incorrect 1 ms 340 KB Output isn't correct
8 Incorrect 4 ms 1232 KB Output isn't correct
9 Incorrect 4 ms 1256 KB Output isn't correct
10 Incorrect 4 ms 1132 KB Output isn't correct
11 Incorrect 10 ms 2008 KB Output isn't correct