CSES - Datatähti 2023 alku - Results
Submission details
Task:Lista
Sender:Laserr
Submission time:2022-11-12 21:58:17 +0200
Language:text (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttimescore
#10.00 s0details

Code

#include<iostream>
#include<vector>
#include<set>

using namespace std;

vector<int> lista(2023, 0);
vector<pair<int, int>> syote;
set<int> loputluvut;

int kasitellyt_luvut;

vector<int> p(2024, 0); 
vector<int> v;
int summa;
int mika;
bool loytynyt;

void haku() {
	if (loytynyt == true)return;
	else if (summa > syote[mika].first) return;

	else if (v.size() == 43) {
		if (summa == syote[mika].first) {
			for (int i = 0; i < 43; i++) {
				lista[i] = v[i];
				loputluvut.insert(v[i]);
				kasitellyt_luvut++;
			}
			loytynyt = true;
		}
		else return;
	}
	else {
		for (int i = 1; i <= 2023; i++) {
			if (p[i] == 1) continue;
			if (loputluvut.count(i) == 1) continue;
			p[i] = 1;
			summa += i;
			v.push_back(i);

			haku();

			summa -= i;
			p[i] = 0;
			v.pop_back();
		}
	}
}

int main() {
	summa = 0;
	mika = 0; 
	kasitellyt_luvut = 0;
	loytynyt = false; 

	for (int i = 0; i < 100; i++) {
		int x;
		cin >> x;
		syote.push_back({ x, i });
	}

	haku();

	for (int i = kasitellyt_luvut; i < 2023; i++) {
		for (int j = 1; j <= 2023; j++) {
			if (loputluvut.count(j) == 0) {
				lista[i] = j;
				loputluvut.insert(j);
				break;
			}
		}
	}

	for (int i : lista) cout << i << " ";
}

Test details

Test 1

Verdict:

input
58667 68283 64141 69169 67564 ...

correct output
688 488 1060 602 1171 471 322 ...

user output
#include<iostream>
#include<vector>
#include<set>

using namespace std;
...