CSES - Datatähti 2020 alku - Results
Submission details
Task:Ruudukko
Sender:sk3
Submission time:2019-10-02 23:11:43 +0300
Language: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.06 sdetails
#6ACCEPTED0.06 sdetails

Code

#include <iostream>
using namespace std;

int main(){
  int in;
	cin >> in;
	
  int test, out[in][in] = {0};
	bool pass;

	for (int y=0; y<in; y++){
	  for (int x=0; x<in; x++){
			
			test = 1;

			while(true){
				pass = true;
				for (int tx = x; tx >= 0; tx--){
					if (out[tx][y] == test) {pass=false;} 
				}
	 			for (int ty = y; ty >= 0; ty--){
					if (out[x][ty] == test) {pass=false;} 
				}

				if (pass == true){break;} else {test++;}
			}
			out[x][y] = test;

		}
	}
	
	for (int y=0; y<in; y++){
	  for (int x=0; x<in; x++){
			if (x < in-1){cout << out[x][y] << " ";} else {cout << out[x][y];}		
		}
		cout << endl;
	}		
		
  return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
1

correct output

user output
1

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 ...

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 ...

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 ...