CSES - Datatähti 2020 alku - Results
Submission details
Task:Ruudukko
Sender:toveri_heino
Submission time:2019-10-04 20:17:07 +0300
Language:C++17
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.01 sdetails
#20.00 sdetails
#30.01 sdetails
#40.01 sdetails
#50.04 sdetails
#60.04 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~

Code

#include <stdio.h>

int is_int(int a, int b[], int n) {
	int res = 0;
	int i=1;
	while (i<=n) {
		if (b[i] == a) {
			// printf("_%d_",b[i]);
			res = 1;
			break;
		}
		++i;
	}
	return res;
}
int pick_one(int a[], int b[], int n) {
	int res = 1;
	for (int i_a = 1; i_a<=n;i_a++) {
		if((is_int(i_a,a,n) == 0) && (!is_int(i_a,b,n))) {
			res = i_a;
			break;
		};
	}
	return res;
}

int main() {
	int n;
	printf("Syota n: ");
	scanf("%d", &n);

	int his_row[n+1][n+1], his_col[n+1][n+1];

	for(int row = 1; row <= n; row++) {
		for(int col = 1; col <= n; col++) {
			int m = pick_one(his_row[row], his_col[col], n);
			printf("%d ", m);
			his_row[row][col] = m;
			his_col[col][row] = m;
		}
		printf("\n");
	}
	// int g[10] = {0,2,3,4,5,6,7};
	// printf("%d\n", pick_one(g,g,n));
}

Test details

Test 1

Verdict:

input
1

correct output

user output
Syota n: 1 

Test 2

Verdict:

input
2

correct output
1 2 
2 1 

user output
Syota n: 1 2 
2 1 

Test 3

Verdict:

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
Syota n: 2 1 3 4 5 
3 2 1 5 4 
1 3 2 1 1 
4 5 1 2 3 
5 4 1 3 2 

Test 4

Verdict:

input
42

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

user output
Syota n: 1 2 3 4 5 6 7 8 9 10 ...

Test 5

Verdict:

input
99

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

user output
Syota n: 1 2 3 4 5 6 7 8 9 10 ...

Test 6

Verdict:

input
100

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

user output
Syota n: 1 2 3 4 5 6 7 8 9 10 ...