답안 #496931

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
496931 2021-12-22T07:11:13 Z abc864197532 DEL13 (info1cup18_del13) C++17
12 / 100
500 ms 332 KB
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define X first
#define Y second
#define pii pair<int,int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T i, U ...j) {
	cout << i << ' ', abc(j...);
}
template <typename T> void printv(T l, T r) {
	for (; l != r; ++l) 
		cout << *l << " \n"[l + 1 == r];
}
#ifdef Doludu
#define test(x...) abc("[" + string(#x) + "]", x);
#else
#define test(x...) void(0);
#endif
const int N = 1001;

bool ask (vector <int> now, vector <int> goal) {
	if (now == goal)
		return true;
	for (int i : goal) if (!count(all(now), i))
		return false;
	for (int i = 1; i + 1 < now.size(); ++i) {
		vector <int> a = now;
		a.erase(a.begin() + i - 1);
		a.erase(a.begin() + i);
		if (ask(a, goal))
			return true;
	}
	return false;
}

int main () {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t;
	cin >> t;
	while (t--) {
		int n, m;
		cin >> n >> m;
		vector <int> a(m), b(n);
		for (int i = 0; i < m; ++i) {
			cin >> a[i], --a[i];
		}
		iota(all(b), 0);
		if (ask(b, a)) {
			cout << 0 << endl << endl;
		} else {
			cout << -1 << endl;
		}
	}
}

Compilation message

del13.cpp: In function 'bool ask(std::vector<int>, std::vector<int>)':
del13.cpp:32:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for (int i = 1; i + 1 < now.size(); ++i) {
      |                  ~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is partially correct
2 Correct 3 ms 204 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is partially correct
2 Correct 3 ms 204 KB Output is partially correct
3 Correct 70 ms 320 KB Output is partially correct
4 Correct 97 ms 312 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1081 ms 204 KB Time limit exceeded
2 Execution timed out 1059 ms 204 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is partially correct
2 Correct 3 ms 204 KB Output is partially correct
3 Correct 70 ms 320 KB Output is partially correct
4 Correct 97 ms 312 KB Output is partially correct
5 Execution timed out 1078 ms 204 KB Time limit exceeded
6 Execution timed out 1085 ms 204 KB Time limit exceeded
7 Execution timed out 1076 ms 300 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is partially correct
2 Correct 3 ms 204 KB Output is partially correct
3 Correct 70 ms 320 KB Output is partially correct
4 Correct 97 ms 312 KB Output is partially correct
5 Execution timed out 1078 ms 204 KB Time limit exceeded
6 Execution timed out 1085 ms 204 KB Time limit exceeded
7 Execution timed out 1076 ms 300 KB Time limit exceeded
8 Execution timed out 1080 ms 204 KB Time limit exceeded
9 Execution timed out 1082 ms 204 KB Time limit exceeded
10 Execution timed out 1080 ms 332 KB Time limit exceeded
11 Execution timed out 1052 ms 332 KB Time limit exceeded