Submission #762512

# Submission time Handle Problem Language Result Execution time Memory
762512 2023-06-21T12:51:32 Z Trunkty DEL13 (info1cup18_del13) C++14
15 / 100
7 ms 1832 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 or v.back()!=0){
            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++){
      |                     ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Incorrect 1 ms 212 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Incorrect 3 ms 340 KB Output isn't correct
4 Incorrect 3 ms 340 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 468 KB Output is correct
2 Correct 2 ms 1212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Incorrect 3 ms 340 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 212 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Incorrect 3 ms 340 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 212 KB Output isn't correct
8 Incorrect 4 ms 976 KB Output isn't correct
9 Incorrect 4 ms 968 KB Output isn't correct
10 Incorrect 4 ms 984 KB Output isn't correct
11 Incorrect 7 ms 1832 KB Output isn't correct