CSES - Putka Open 2020 – 5/5 - Results
Submission details
Task:HQ9+
Sender:ArktinenKarpalo
Submission time:2020-11-27 18:13:25 +0200
Language:C++ (C++17)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED15
#2ACCEPTED85
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2details
#2ACCEPTED0.01 s2details

Code

#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define M 1000000007
 
using namespace std;

int t;
int d[101010];
char o[101010];

int main() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio();
	cin >> t;
	for(int i=0; i<=100000; i++)
		d[i] = 1e9;

	d[0] = 0;
	for(int i=0; i<100000; i++) {
			// H = 1
			if(d[i]+1 < d[i+1]) {
				d[i+1] = d[i]+1;
				o[i+1] = 'Q';
			}
			if(d[i]+1 < d[i+494]) {
				d[i+494] = d[i]+1;
				o[i+494] = '9';
			}
			// 9 = 494
	}
	for(int g=0; g<t; g++) {
		int pnt;
		cin >> pnt;
		while(pnt > 0) {
			cout << o[pnt];
			if(o[pnt] == '9')
				pnt -= 494;
			else
				pnt--;
		}
		cout << "\n";
	}
}

Test details

Test 1

Group: 1, 2

Verdict: ACCEPTED

input
100
10
96
42
77
...

correct output
HHHHHHHHHH
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH...

user output
QQQQQQQQQQ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...
Truncated

Test 2

Group: 2

Verdict: ACCEPTED

input
100
76364
26254
35192
92572
...

correct output
999999999999999999999999999999...

user output
999999999999999999999999999999...
Truncated