QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#375395#4088. 총 쏘기Unknown15080 1ms3768kbC++201.3kb2024-04-03 10:06:582024-04-03 10:06:58

Judging History

你现在查看的是最新测评结果

  • [2024-04-03 10:06:58]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3768kb
  • [2024-04-03 10:06:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ii = pair<int, int>;

int find_bad(const vector<int> &A, int limit = 1e9){
	int res = (limit == 0) ? -1 : 0, mx = -1;
	for (int i = 0; i < min(limit, (int)A.size() - 1); i++){
		if (A[i] <= mx) continue;
		if (A[i] > A[i+1]){
			res = i;
		}
		mx = max(mx, A[i]);
	}
	
	return res;
}

void remove(vector<int> &A, int idx){
	vector<int> newA;
	for (int i = 0; i < (int)A.size(); i++){
		if (i != idx) newA.push_back(A[i]);
	}
	swap(A, newA);
}

vector<ii> min_shooting_buildings(vector<int> A){
	if ((int)A.size() == 0) return {};
	if ((int)A.size() == 1) return {{A[0], A[0]}};

	int f1 = find_bad(A);
	if (f1 < 0){
		vector<ii> res = {{A[0], A[1]}};
		remove(A, 0); remove(A, 0);
		vector<ii> recur = min_shooting_buildings(A);
		res.insert(res.end(), recur.begin(), recur.end());
		return res;
	}

	int value = A[f1];
	remove(A, f1);
	int f2 = find_bad(A, f1);

	if (f2 < 0){
		vector<ii> res = {{value, value}};
		vector<ii> recur = min_shooting_buildings(A);
		res.insert(res.end(), recur.begin(), recur.end());
		return res;
	}

	vector<ii> res = {{value, A[f2]}};
	remove(A, f2);

	vector<ii> recur = min_shooting_buildings(A);
	res.insert(res.end(), recur.begin(), recur.end());
	return res;
}


詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3760kb

input:

8
4 3 8 2 1 7 6 5

output:

5
8 4
7 3
6 2
1 1
5 5

result:

wrong answer Incorrect

Subtask #2:

score: 0
Wrong Answer

Test #26:

score: 0
Wrong Answer
time: 0ms
memory: 3724kb

input:

8
5 6 7 1 2 8 3 4

output:

6
8 7
6 5
1 1
2 2
3 3
4 4

result:

wrong answer Incorrect

Subtask #3:

score: 0
Wrong Answer

Test #51:

score: 9
Accepted
time: 0ms
memory: 3760kb

input:

1
1

output:

1
1 1

result:

ok Correct

Test #52:

score: -9
Wrong Answer
time: 0ms
memory: 3768kb

input:

2
1 2

output:

2
1 1
2 2

result:

wrong answer Incorrect

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

0%