CSES - Datatähti 2018 alku - Results
Submission details
Task:Merkkijono
Sender:luxask
Submission time:2017-10-06 19:50:42 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.04 sdetails
#2ACCEPTED0.05 sdetails
#3ACCEPTED0.04 sdetails
#40.04 sdetails
#50.05 sdetails
#60.04 sdetails
#70.04 sdetails
#80.05 sdetails
#90.04 sdetails
#100.04 sdetails

Code

#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

vector<int> getIndexes() {
	int count, num;
    vector<int> indexes;
    cin >> count;

    for (int i = 0; i < count; ++i)
    {
    	cin >> num;
    	indexes.push_back(num);
    }
    return indexes;
}

int f(int x) {
	return 9 * x * pow(10, x-1);
}

int getFirstNumber(int index, int numCount) {
	return floor(index / (numCount * 10)) + 1;
}

int getMiddleNumber(int index, int numCount, int subNumber) {
	return floor(floor(index / numCount) / pow(10, numCount - subNumber));
}

int getLastNumber(int index, int numCount) {
	return ((index / numCount) - 1) % 10;
}

int getNumberFromIndex(int index) {
	if (index <= 9)
		return index;

	int numCount = 1;
	while (index >= f(numCount)) {
		index -= f(numCount);
		numCount++;
	}
	switch (int subNumber = index % numCount){
		case 0:
			return getLastNumber(index, numCount);
			break;
		case 1:
			return getFirstNumber(index, numCount);
			break;
		default:
			return getMiddleNumber(index, numCount, subNumber);
			break;
	}
}

void fake() {
	for (unsigned i=1; i<50; i++)
    	cout << getNumberFromIndex(i);
}

void real() {
	auto indexes = getIndexes();
    for (unsigned i=0; i<indexes.size(); i++)
    	cout << getNumberFromIndex(indexes.at(i)) << '\n';
}

int main() {
	real();
    return 0;
}

Test details

Test 1

Verdict:

input
ABABABABABABABABABABABABABABAB...

correct output
ABABABABABABABABABABABABABABAB...

user output
(empty)

Test 2

Verdict: ACCEPTED

input
AABBAABBAABBAABBAABBAABBAABBAA...

correct output
(empty)

user output
(empty)

Test 3

Verdict: ACCEPTED

input
ABABABABABABABABABABABABABABAB...

correct output
(empty)

user output
(empty)

Test 4

Verdict:

input
BBABABBBBBAABBBABABABBBBAAABAB...

correct output
BAB

user output
(empty)

Test 5

Verdict:

input
ACDCBBACDBBBACAACBBDBADBAABABA...

correct output
ACDCACDADBADABACACDCADADABABCA...

user output
(empty)

Test 6

Verdict:

input
EETFHIJOGACDHMGVFJCMETMZDEITTR...

correct output
TFHIJOGACDHMGVFJCMETMZDEIROTET...

user output
(empty)

Test 7

Verdict:

input
GOONLAHLYPRFCZKIKSJWAWWYJJPCDB...

correct output
GNLAHLYPRFCZKIKSJWAYPCDNWYMRCE...

user output
(empty)

Test 8

Verdict:

input
PISHWMOTCDDZFRMYMOMYDYYGJZIQHS...

correct output
PISHWMOTCZFRMYMOMYDGJZIQHSVAOK...

user output
(empty)

Test 9

Verdict:

input
QUVVTPXAMWWODFXRONJODPGBTCISGM...

correct output
QUTPXAMODFXRONJODPGBTCISGMVRBW...

user output
(empty)

Test 10

Verdict:

input
POXHAHYEZTLYNFSLABODMRNKDSKROZ...

correct output
POXHAHYEZTLYNFSLABODMRNKDSKROZ...

user output
(empty)