Submission #317036

# Submission time Handle Problem Language Result Execution time Memory
317036 2020-10-29T01:13:39 Z Kevin_Zhang_TW DEL13 (info1cup18_del13) C++17
6 / 100
7 ms 1152 KB
#include<bits/stdc++.h>
#define pb emplace_back
#define AI(i) begin(i), end(i)
using namespace std;
using ll = long long;
#undef KEV
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] : ", args)
void kout() { cerr << endl; }
template<class T, class ...U>
void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
void debug(auto L, auto R) { while (L != R) cerr << *L << " \n"[next(L) == R], ++L; }
#else
#define debug(...) 0
#define DE(...) 0
#endif
const int MAX_N = 300010;
int len, m, p[MAX_N];
bool valid() {
	DE(len, m);
	if ((len ^ m) & 1)
		return false;
	++m;
	vector<int> dis;
	for (int i = 1;i <= m;++i)
		dis.pb(p[i]-p[i-1]-1);
	//cerr << "dis\n";
	debug(AI(dis));
	for (int &u : dis) {
		if (u <= 1) continue;
		u = (u&1 ? 1 : 2);
	}
	//cerr << "After\n";
	debug(AI(dis));

	for (int i = 0;i+1 < m;++i) {
		if (dis[i] == 0) continue;
		if (dis[i] < 0) return false;
		while (dis[i]--)
			dis[i+1]--;
	}
	return dis.back() == 0;
}
void solve() {
	cin >> len >> m;
	for (int i = 1;i <= m;++i)
		cin >> p[i];
	//cerr << "\n\n";
	p[m+1] = len+1;
	if (!valid()) 
		return cout << -1 << '\n', void();
	cout << 0 << '\n' << '\n' ;
}
int32_t main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int T;
	cin >> T;
	while (T--)
		solve();
}

Compilation message

del13.cpp: In function 'bool valid()':
del13.cpp:15:17: warning: statement has no effect [-Wunused-value]
   15 | #define DE(...) 0
      |                 ^
del13.cpp:20:2: note: in expansion of macro 'DE'
   20 |  DE(len, m);
      |  ^~
del13.cpp:14:20: warning: statement has no effect [-Wunused-value]
   14 | #define debug(...) 0
      |                    ^
del13.cpp:28:2: note: in expansion of macro 'debug'
   28 |  debug(AI(dis));
      |  ^~~~~
del13.cpp:14:20: warning: statement has no effect [-Wunused-value]
   14 | #define debug(...) 0
      |                    ^
del13.cpp:34:2: note: in expansion of macro 'debug'
   34 |  debug(AI(dis));
      |  ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Incorrect 1 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Incorrect 3 ms 384 KB Output isn't correct
4 Incorrect 3 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 464 KB Output is partially correct
2 Correct 2 ms 384 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Incorrect 3 ms 384 KB Output isn't correct
4 Incorrect 3 ms 384 KB Output isn't correct
5 Incorrect 1 ms 384 KB Output isn't correct
6 Incorrect 1 ms 384 KB Output isn't correct
7 Incorrect 1 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Incorrect 3 ms 384 KB Output isn't correct
4 Incorrect 3 ms 384 KB Output isn't correct
5 Incorrect 1 ms 384 KB Output isn't correct
6 Incorrect 1 ms 384 KB Output isn't correct
7 Incorrect 1 ms 384 KB Output isn't correct
8 Incorrect 5 ms 640 KB Output isn't correct
9 Incorrect 6 ms 936 KB Output isn't correct
10 Incorrect 7 ms 940 KB Output isn't correct
11 Incorrect 6 ms 1152 KB Output isn't correct