QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#614312#8837. Increasing Incomeucup-team2432#WA 1ms3784kbC++201.4kb2024-10-05 16:09:202024-10-05 16:09:25

Judging History

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

  • [2024-10-05 16:09:25]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3784kb
  • [2024-10-05 16:09:20]
  • 提交

answer

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define sz(vec) ((ll)vec.size())
#define all(vec) vec.begin(),vec.end()
#define umap __gnu_pbds::gp_hash_table
using ll = long long;
using db = double;
#define Emu Smile
using namespace std;

void chmax(auto &a, auto b) { if (a < b) a = b; }
void chmin(auto &a, auto b) { if (a > b) a = b; }
inline int lbt(int x) { return x & (-x); }

const ll inf = 1e16;

void solve() {
	int n; cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; ++i) {
		cin >> p[i]; p[i] --;
	}
	int res1 = 0, res2 = 0;
	{
		for (int i = 0, j = -1; i < n; ++i) {
			if (p[i] > j) {
				res1 ++; j = p[i];
			}
		}
		res1 += n;
	}
	vector<int> q(n);
	for (int i = 0; i < n; ++i) {
		q[p[i]] = i;
	}
	{
		for (int i = 0, j = -1; i < n; ++i) {
			if (q[i] > j) {
				res2 ++; j = q[i];
			}
		}
		res2 += n;
	}
	if (res1 >= res2) {
		vector<int> ret(n);
		iota(all(ret), 0);
		for (auto x : ret) {
			cout << x + 1 << " ";
		}
		cout << '\n';
	} else {
		for (auto x : q) {
			cout << x + 1 << " ";
		}
		cout << '\n';
	}
}

int main() {

	ios::sync_with_stdio(false);
	cin.tie(nullptr);

//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);

//	init();

	cout << fixed << setprecision(2);

	int OuO = 1;
	cin >> OuO;
	for (int piastic = 0; piastic < OuO; ++piastic) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3784kb

input:

3
3
1 2 3
4
2 4 3 1
5
1 5 2 4 3

output:

1 2 3 
1 2 3 4 
1 3 5 4 2 

result:

ok Correct (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3612kb

input:

153
4
2 4 3 1
4
1 4 2 3
5
2 1 4 5 3
5
1 4 5 3 2
4
1 3 2 4
5
1 5 2 4 3
5
5 3 1 2 4
5
4 1 2 5 3
5
1 2 5 3 4
5
3 1 4 2 5
5
5 4 2 3 1
5
2 1 5 4 3
5
3 4 1 5 2
5
1 4 3 5 2
5
5 1 3 4 2
5
5 3 2 4 1
5
1 5 3 2 4
5
2 4 3 1 5
5
1 5 4 3 2
5
1 2 4 5 3
5
4 2 5 3 1
5
1 3 5 2 4
5
3 1 4 5 2
3
2 1 3
5
1 2 4 3 5
5
5 1 ...

output:

1 2 3 4 
1 3 4 2 
1 2 3 4 5 
1 2 3 4 5 
1 2 3 4 
1 3 5 4 2 
3 4 2 5 1 
2 3 5 1 4 
1 2 4 5 3 
1 2 3 4 5 
1 2 3 4 5 
1 2 3 4 5 
1 2 3 4 5 
1 2 3 4 5 
2 5 3 4 1 
1 2 3 4 5 
1 4 3 5 2 
1 2 3 4 5 
1 2 3 4 5 
1 2 3 4 5 
1 2 3 4 5 
1 2 3 4 5 
1 2 3 4 5 
1 2 3 
1 2 3 4 5 
2 3 5 4 1 
3 4 1 5 2 
3 5 4 2 1 
1 ...

result:

wrong answer Jury found better answer than participant (test case 11)