Submission #1066986

# Submission time Handle Problem Language Result Execution time Memory
1066986 2024-08-20T09:19:16 Z 김은성(#11121) Gardening (RMI21_gardening) C++17
21 / 100
12 ms 860 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[8][200009];
int n, m;
bool rev = 0;
int cnt = 0;
void fill1(int r0, int c0, int rows, int cols){
	cnt++;
	for(int i=0; i<rows; i++)
		for(int j=0; j<cols; j++)
			a[r0+i][c0+j] = cnt;
}
void printanswer(){
	printf("YES\n");
	if(rev){
		for(int i=0; i<m; i++){
			for(int j=0; j<n; j++)
				printf("%d ", a[j][i]);
			printf("\n");
		}
	}
	else{
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++)
				printf("%d ", a[i][j]);
			printf("\n");
		}
	}
}
void fill2(int r0, int c0, int m){
	for(int i=0; i<m; i+=2)
		fill1(r0, c0 + i, 2, 2);
}
void fill4(int r0, int c0, int m, int k){
	assert(m/2 <= k && k <= m && k != m-1);
	for(int i=0; i<2*k-m; i+=2){
		fill1(0 + r0, i + c0, 2, 2);
		fill1(2 + r0, i + c0, 2, 2);
	}
	fill1(0 + r0, 2*k-m + c0, 4, 2*(m-k));
	for(int i=2*k-m+1; i<m-1; i+=2){
		//printf("i=%d c0=%d\n", i, c0);
		fill1(1 + r0, i + c0, 2, 2);
	}
}
int main(){
	ll k;
	int t, i, j;
	scanf("%d", &t);
	while(t--){
		scanf("%d %d %lld", &n, &m, &k);
		cnt = 0;
		if(n%2 || m%2){
			printf("NO\n");
			continue;
		}
		rev = 0;
		if(n > m){
			rev = 1;
			swap(n, m);
		}
		if(k == m/2){
			for(i=0; i<n; i++){
				for(j=0; j<m; j++){
					if(min(min(i+1, n-i), min(j+1, m-j)) < n/2)
						a[i][j] = min(min(i+1, n-i), min(j+1, m-j));
					else
						a[i][j] = n/2 + (j+1-n/2)/2;
				}
			}
			printanswer();
		}
		else if(k == n*m/4){
			for(i=0; i<n; i++){
				for(j=0; j<m; j++){
					a[i][j] = i/2 * m/2 + j/2 + 1;
				}
			}
			printanswer();
		}
		else if(n==2){
			if(k == m/2){
				fill2(0, 0, m);
				printanswer();
			}
			else
				printf("NO\n");
		}
		else if(n==4){
			if(m/2 <= k && k <= m && k != m-1){
				fill4(0, 0, m, k);
				printanswer();
			}
			else
				printf("NO\n");
		}
		else if(n==6){
			if(k < m/2+1 || k > 3*m/2 - 2)
				printf("NO\n");
			else if(k >= m){
				fill2(4, 0, m);
				fill4(0, 0, m, k-m/2);
				printanswer();
			}
			else if(k == m-2){
				if(m==6){
					printf("NO\n");
					continue;
				}
				m -= 2;
				k -= 3;
				fill1(0, 0, n, m);
				fill4(1, 1, m-2, k-1);
				fill1(0, m, 2, 2);
				fill1(2, m, 2, 2);
				fill1(4, m, 2, 2);
				m += 2;
				printanswer();
			}
			else{
				fill1(0, 0, n, m);
				fill4(1, 1, m-2, k-1);
				printanswer();
			}
		}
	}
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:50:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |  scanf("%d", &t);
      |  ~~~~~^~~~~~~~~~
Main.cpp:52:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |   scanf("%d %d %lld", &n, &m, &k);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 860 KB Correct! Azusa and Laika like the garden :)
# Verdict Execution time Memory Grader output
1 Correct 12 ms 860 KB Correct! Azusa and Laika like the garden :)
2 Correct 7 ms 604 KB Correct! Azusa and Laika like the garden :)
3 Correct 8 ms 600 KB Correct! Azusa and Laika like the garden :)
# Verdict Execution time Memory Grader output
1 Correct 12 ms 860 KB Correct! Azusa and Laika like the garden :)
2 Correct 7 ms 604 KB Correct! Azusa and Laika like the garden :)
3 Correct 8 ms 600 KB Correct! Azusa and Laika like the garden :)
4 Correct 7 ms 600 KB Correct! Azusa and Laika like the garden :)
5 Correct 8 ms 604 KB Correct! Azusa and Laika like the garden :)
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 0 ms 344 KB Incorrect output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 860 KB Correct! Azusa and Laika like the garden :)
2 Correct 7 ms 604 KB Correct! Azusa and Laika like the garden :)
3 Correct 8 ms 600 KB Correct! Azusa and Laika like the garden :)
4 Correct 7 ms 600 KB Correct! Azusa and Laika like the garden :)
5 Correct 8 ms 604 KB Correct! Azusa and Laika like the garden :)
6 Runtime error 1 ms 600 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -