CSES - Datatähti 2020 alku - Results
Submission details
Task:Ruudukko
Sender:ArturT
Submission time:2019-10-06 14:24:19 +0300
Language:C++ (C++11)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.01 sdetails
#3ACCEPTED0.01 sdetails
#4ACCEPTED0.01 sdetails
#5ACCEPTED0.02 sdetails
#6ACCEPTED0.02 sdetails

Code

#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;


int main() {
	int seed;
	cin >> seed;
	vector <int> table;
	table.reserve(seed * seed);
	for (int row = 0; row < seed; row++) { // for each row
		
		vector<int> buff = {};
		for (int b = 1; b <= seed; b++) { // for each number
			buff = {};
			for (int c = 0; c < row; c++) { // for each previous row
				buff.push_back(table[c * (seed) + b-1]); // add numbers up to buffer 
			} 
			for (int d = 0; d < b-1; d++) { // for
				buff.push_back(table[(row)*seed+d]);
			}
			bool found = false;
			int i = 1;
			while (!found) {// check if buffer contains proposed character
				if (!(find(buff.begin(), buff.end(), i) != buff.end())) {
					std::cout << i << " ";
					table.push_back(i);
					if (b == seed) {
						std::cout << std::endl;
					}
					else {
						buff.push_back(i); // add numbers on the left to buffer
					}
					//table.push_back(i);
					found = true;
				}
				i++;
			}
		}
}

	}

Test details

Test 1

Verdict: ACCEPTED

input
1

correct output

user output

Test 2

Verdict: ACCEPTED

input
2

correct output
1 2 
2 1 

user output
1 2 
2 1 

Test 3

Verdict: ACCEPTED

input
5

correct output
1 2 3 4 5 
2 1 4 3 6 
3 4 1 2 7 
4 3 2 1 8 
5 6 7 8 1 

user output
1 2 3 4 5 
2 1 4 3 6 
3 4 1 2 7 
4 3 2 1 8 
5 6 7 8 1 

Test 4

Verdict: ACCEPTED

input
42

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...
Truncated

Test 5

Verdict: ACCEPTED

input
99

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...
Truncated

Test 6

Verdict: ACCEPTED

input
100

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...
Truncated