Code Submission Evaluation System Login

Datatähti 2017 loppu

Start:2017-01-19 12:15:00
End:2017-01-19 17:15:00
 

Tasks | Messages | Scoreboard | Statistics


CSES - Datatähti 2017 loppu - Results
History
2017-01-19 15:16:370
Task:Ruudukko
Sender:while(false)
Submission time:2017-01-19 15:16:37
Language:C++
Status:READY
Score:0

Feedback

groupverdictscore
#1TIME LIMIT EXCEEDED0
#2TIME LIMIT EXCEEDED0
#3TIME LIMIT EXCEEDED0

Test results

testverdicttime (s)group
#1ACCEPTED0.04 / 1.001details
#2ACCEPTED0.03 / 1.001details
#3ACCEPTED0.04 / 1.001details
#4ACCEPTED0.03 / 1.001details
#5ACCEPTED0.87 / 1.001details
#6TIME LIMIT EXCEEDED-- / 1.001details
#7TIME LIMIT EXCEEDED-- / 1.001details
#8TIME LIMIT EXCEEDED-- / 1.001details
#9TIME LIMIT EXCEEDED-- / 1.001details
#10ACCEPTED0.04 / 1.002details
#11ACCEPTED0.03 / 1.002details
#12TIME LIMIT EXCEEDED-- / 1.002details
#13TIME LIMIT EXCEEDED-- / 1.002details
#14TIME LIMIT EXCEEDED-- / 1.002details
#15TIME LIMIT EXCEEDED-- / 1.002details
#16ACCEPTED0.04 / 1.003details
#17ACCEPTED0.04 / 1.003details
#18TIME LIMIT EXCEEDED-- / 1.003details
#19TIME LIMIT EXCEEDED-- / 1.003details
#20TIME LIMIT EXCEEDED-- / 1.003details
#21TIME LIMIT EXCEEDED-- / 1.003details

Code

#include <iostream>
using namespace std;

int n;
int sumX[1000];
int sumY[1000];
int grid[1000][1000];
int num[1001];

int search(int x, int y, int a);
bool many(int s);

int main(){
	cin >> n;
	for (int i=0;i<n;i++){
		sumX[i]=0;
		sumY[i]=0;
		num[i]=0;
	}
	for (int i=1;i<=n;i++){
		if (search(0,0,i)) return 0;
	}
	cout << "QAQ";
	return 0;
}

int search(int x, int y, int a){
	grid[x][y]=a;
	num[a]++;
	sumX[x]+=a;
	sumY[y]+=a;
	if ((num[a]<=n)&&(y!=n-1||!many(sumX[x]))&&(x!=n-1||!many(sumY[y]))){
		if (x!=n-1) {for (int i=1;i<=n;i++){
			if (search(x+1,y,i)) return 1;
		}}
		else if (y!=n-1) {for (int i=1;i<=n;i++){
			if (search(0,y+1,i)) return 1;
		}}
		else {
			for (int i=0;i<n;i++){
				for (int j=0;j<n;j++){cout << grid[i][j] << ' ';}
				cout << '\n';
			}
			return 1;
		}
	}
	grid[x][y]=0;
	num[a]--;
	sumX[x]-=a;
	sumY[y]-=a;
	return 0;
}

bool many(int s){
	bool t=false;
	for (int i=0;i<n;i++){
		if (sumX[i]==s){
			if (t){return true;}
			t=true;
		}
		if (sumY[i]==s){
			if (t){return true;}
			t=true;
		}
	}
	return false;
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
2
view   save

correct output
QAQ
view   save

user output
QAQ
view   save

Test 2

Group: 1

Verdict: ACCEPTED

input
3
view   save

correct output
QAQ
view   save

user output
QAQ
view   save

Test 3

Group: 1

Verdict: ACCEPTED

input
4
view   save

correct output
3 4 3 4
3 1 1 2
4 4 3 2
2 2 1 1
view   save

user output
1 1 2 3
1 2 3 4
1 3 4 3
2 2 4 4
view   save

Test 4

Group: 1

Verdict: ACCEPTED

input
5
view   save

correct output
2 3 4 1 1
3 4 2 1 2
4 2 3 1 3
4 3 2 1 4
5 5 5 5 5
view   save

user output
1 2 3 3 4
1 2 3 3 5
1 2 3 4 5
1 2 4 5 4
1 2 5 4 5
view   save

Test 5

Group: 1

Verdict: ACCEPTED

input
6
view   save

correct output
2 3 4 5 1 1
3 4 5 2 1 2
4 5 2 3 1 3
5 2 3 4 1 4
5 4 3 2 1 5
6 6 6 6 6 6
view   save

user output
1 2 3 4 4 4
1 2 3 5 6 6
1 2 3 3 4 4
1 2 3 5 5 5
1 2 3 5 5 6
1 2 4 6 6 6
view   save

Test 6

Group: 1

Verdict: TIME LIMIT EXCEEDED

input
7
view   save

correct output
2 3 4 5 6 1 1
3 4 5 6 2 1 2
4 5 6 2 3 1 3
5 6 2 3 4 1 4
6 2 3 4 5 1 5
6 5 4 3 2 1 6
7 7 7 7 7 7 7
view   save

user output
(empty)
view   save

Test 7

Group: 1

Verdict: TIME LIMIT EXCEEDED

input
8
view   save

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

user output
(empty)
view   save

Test 8

Group: 1

Verdict: TIME LIMIT EXCEEDED

input
9
view   save

correct output
2 3 4 5 6 7 8 1 1
3 4 5 6 7 8 2 1 2
4 5 6 7 8 2 3 1 3
5 6 7 8 2 3 4 1 4
6 7 8 2 3 4 5 1 5
7 8 2 3 4 5 6 1 6
8 2 3 4 5 6 7 1 7
8 7 6 5 4 3 2 1 8
9 9 9 9 9 9 9 9 9
view   save

user output
(empty)
view   save

Test 9

Group: 1

Verdict: TIME LIMIT EXCEEDED

input
10
view   save

correct output
2 3 4 5 6 7 8 9 1 1
3 4 5 6 7 8 9 2 1 2
4 5 6 7 8 9 2 3 1 3
5 6 7 8 9 2 3 4 1 4
6 7 8 9 2 3 4 5 1 5
7 8 9 2 3 4 5 6 1 6
8 9 2 3 4 5 6 7 1 7
9 2 3 4 5 6 7 8 1 8
9 8 7 6 5 4 3 2 1 9
10 10 10 10 10 10 10 10 10 10
view   save

user output
(empty)
view   save

Test 10

Group: 2

Verdict: ACCEPTED

input
3
view   save

correct output
QAQ
view   save

user output
QAQ
view   save

Test 11

Group: 2

Verdict: ACCEPTED

input
4
view   save

correct output
3 4 3 4
3 1 1 2
4 4 3 2
2 2 1 1
view   save

user output
1 1 2 3
1 2 3 4
1 3 4 3
2 2 4 4
view   save

Test 12

Group: 2

Verdict: TIME LIMIT EXCEEDED

input
29
view   save

correct output
2 3 4 5 6 7 8 9 10 11 12 13 14...
3 4 5 6 7 8 9 10 11 12 13 14 1...
4 5 6 7 8 9 10 11 12 13 14 15 ...
5 6 7 8 9 10 11 12 13 14 15 16...
6 7 8 9 10 11 12 13 14 15 16 1...
7 8 9 10 11 12 13 14 15 16 17 ...
8 9 10 11 12 13 14 15 16 17 18...
9 10 11 12 13 14 15 16 17 18 1...
10 11 12 13 14 15 16 17 18 19 ...
11 12 13 14 15 16 17 18 19 20 ...
12 13 14 15 16 17 18 19 20 21 ...
13 14 15 16 17 18 19 20 21 22 ...
14 15 16 17 18 19 20 21 22 23 ...
view   save

user output
(empty)
view   save

Test 13

Group: 2

Verdict: TIME LIMIT EXCEEDED

input
48
view   save

correct output
2 3 4 5 6 7 8 9 10 11 12 13 14...
3 4 5 6 7 8 9 10 11 12 13 14 1...
4 5 6 7 8 9 10 11 12 13 14 15 ...
5 6 7 8 9 10 11 12 13 14 15 16...
6 7 8 9 10 11 12 13 14 15 16 1...
7 8 9 10 11 12 13 14 15 16 17 ...
8 9 10 11 12 13 14 15 16 17 18...
9 10 11 12 13 14 15 16 17 18 1...
view   save

user output
(empty)
view   save

Test 14

Group: 2

Verdict: TIME LIMIT EXCEEDED

input
80
view   save

correct output
2 3 4 5 6 7 8 9 10 11 12 13 14...
3 4 5 6 7 8 9 10 11 12 13 14 1...
4 5 6 7 8 9 10 11 12 13 14 15 ...
5 6 7 8 9 10 11 12 13 14 15 16...
6 7 8 9 10 11 12 13 14 15 16 1...
view   save

user output
(empty)
view   save

Test 15

Group: 2

Verdict: TIME LIMIT EXCEEDED

input
97
view   save

correct output
2 3 4 5 6 7 8 9 10 11 12 13 14...
3 4 5 6 7 8 9 10 11 12 13 14 1...
4 5 6 7 8 9 10 11 12 13 14 15 ...
5 6 7 8 9 10 11 12 13 14 15 16...
view   save

user output
(empty)
view   save

Test 16

Group: 3

Verdict: ACCEPTED

input
3
view   save

correct output
QAQ
view   save

user output
QAQ
view   save

Test 17

Group: 3

Verdict: ACCEPTED

input
4
view   save

correct output
3 4 3 4
3 1 1 2
4 4 3 2
2 2 1 1
view   save

user output
1 1 2 3
1 2 3 4
1 3 4 3
2 2 4 4
view   save

Test 18

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
111
view   save

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

user output
(empty)
view   save

Test 19

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
506
view   save

correct output
2 3 4 5 6 7 8 9 10 11 12 13 14...
view   save

user output
(empty)
view   save

Test 20

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
844
view   save

correct output
2 3 4 5 6 7 8 9 10 11 12 13 14...
view   save

user output
(empty)
view   save

Test 21

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
991
view   save

correct output
2 3 4 5 6 7 8 9 10 11 12 13 14...
view   save

user output
(empty)
view   save