CSES - Datatähti 2018 peili - Results
Submission details
Task:Merkkijono
Sender:johku90
Submission time:2017-10-05 22:20:10 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.04 sdetails
#2ACCEPTED0.05 sdetails
#3ACCEPTED0.05 sdetails
#40.05 sdetails
#50.04 sdetails
#60.06 sdetails
#70.06 sdetails
#80.04 sdetails
#90.04 sdetails
#100.04 sdetails

Compiler report

input/code.cpp: In function 'std::string getNumber(int)':
input/code.cpp:15:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(column + s.length() >= k){
                             ^

Code

#include <iostream>
#include <sstream>
#include <string.h>

using namespace std;

//12345678910111213141516171819202122232425

string getNumber(int k){
	int column = 0;
	for(int n = 1; true; n++){
		stringstream ss;
		ss<<n;
		string s = ss.str();
		if(column + s.length() >= k){
			int index = k - column;
			return s.substr(index - 1, 1);
		}
		
		column += s.length();
	}
}

int main(){
	int num;
    cin >> num;
    
	int* kArray = new int[num];
	
	for(int n=0; n<num; n++){
		int k;
		cin >> k;
		kArray[n] = k;
	}
	for(int n=0; n<num; n++){
		cout<<getNumber(kArray[n])<<endl;
	}
	
	delete [] kArray;
	
	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)