답안 #637067

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
637067 2022-08-31T11:39:17 Z Dec0Dedd DEL13 (info1cup18_del13) C++14
0 / 100
9 ms 468 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 200+1;
int d[N], rm[N];

void solve() {
   int n, q; cin>>n>>q;

   if (q == 0) {
      cout<<0<<"\n";
      return;
   }

   for (int i=0; i<=n; ++i) d[i]=rm[i]=0;
   vector<int> v;
   v.push_back(0);
   for (int i=0; i<q; ++i) {
      int p; cin>>p;
      v.push_back(p);
   }
   q+=2, v.push_back(n+1);

   for (int i=1; i<q; ++i) d[i]=v[i]-v[i-1]-1;

   for (int i=1; i<q-1; ++i) {
      if (d[i]&1) --d[i], --d[i+1], ++rm[i], ++rm[i+1];
      else if (d[i] > 0 && d[i+1] > 0) {
         d[i]-=2, d[i+1]-=2, rm[i]+=2, rm[i+1]+=2;
      }
   }

   bool ok=true;
   for (int i=1; i<q; ++i) {
      if ((d[i]&1) || d[i] < 0) ok=false;
      if (d[i]%2 == 0 && d[i] > 0 && rm[i] == 0) ok=false;
   }

   if (!ok) {
      cout<<-1<<"\n";
   } else {
      cout<<0<<"\n";
   }
}

int main() {
   int t; cin>>t;
   while (t--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 212 KB Output isn't correct
2 Incorrect 2 ms 212 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 212 KB Output isn't correct
2 Incorrect 2 ms 212 KB Output isn't correct
3 Incorrect 9 ms 352 KB Output isn't correct
4 Incorrect 9 ms 340 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Runtime error 2 ms 468 KB Execution killed with signal 11
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 212 KB Output isn't correct
2 Incorrect 2 ms 212 KB Output isn't correct
3 Incorrect 9 ms 352 KB Output isn't correct
4 Incorrect 9 ms 340 KB Output isn't correct
5 Incorrect 2 ms 212 KB Output isn't correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 1 ms 212 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 212 KB Output isn't correct
2 Incorrect 2 ms 212 KB Output isn't correct
3 Incorrect 9 ms 352 KB Output isn't correct
4 Incorrect 9 ms 340 KB Output isn't correct
5 Incorrect 2 ms 212 KB Output isn't correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Runtime error 1 ms 340 KB Execution killed with signal 11
9 Runtime error 1 ms 340 KB Execution killed with signal 11
10 Runtime error 1 ms 340 KB Execution killed with signal 11
11 Runtime error 1 ms 340 KB Execution killed with signal 11