Submission #1141342


Source Code Expand

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

const char choiceChar[5] = "URDL";
char s[50][51];
int f[50][50], d[50][50];

int main(void) {
	int i;
	int r, c, n;
	int score;

	srand(time(NULL));

	scanf("%*d %*d %*d %d %d", &r, &c);
	r--; c--;
	for (i = 0; i < 50; i++)
		scanf("%s", s[i]);
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		int fr, fc, ft, dt;
		scanf("%d %d %d %d", &fr, &fc, &ft, &dt);
		fr--; fc--;
		f[fr][fc] = ft;
		d[fr][fc] = dt;
	}

	score = 0;
	for (i = 0; i < 2500; i++) {
		const int choice = rand() % 4;
		const int nr = r + dr[choice], nc = c + dc[choice];
		if (nr >= 0 && nr < 50 && nc >= 0 && nc < 50 && s[nr][nc] == '.' && f[nr][nc] - d[nr][nc] * i >= 0) {
			putchar(choiceChar[choice]);
			score += f[nr][nc] - d[nr][nc] * i;
			f[nr][nc] = d[nr][nc] = 0;
			r = nr;
			c = nc;
		} else
			putchar('-');
	}
	putchar('\n');

	fprintf(stderr, "%d\n", score);

	return 0;
}

Submission Info

Submission Time
Task B - Food Collector
User zeosutt
Language C (GCC 5.4.1)
Score 2908
Code Size 1035 Byte
Status AC
Exec Time 1 ms
Memory 128 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:19:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%*d %*d %*d %d %d", &r, &c);
  ^
./Main.c:22:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", s[i]);
   ^
./Main.c:23:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ^
./Main.c:26:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %d", &fr, &fc, &ft, &dt);
   ^

Judge Result

Set Name test_01 test_02 test_03 test_04 test_05 test_06 test_07 test_08 test_09 test_10
Score / Max Score 152 / 20000 677 / 20000 412 / 20000 240 / 20000 454 / 20000 265 / 20000 146 / 20000 120 / 20000 289 / 20000 153 / 20000
Status
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
Set Name Test Cases
test_01 subtask_01_01.txt
test_02 subtask_01_02.txt
test_03 subtask_01_03.txt
test_04 subtask_01_04.txt
test_05 subtask_01_05.txt
test_06 subtask_01_06.txt
test_07 subtask_01_07.txt
test_08 subtask_01_08.txt
test_09 subtask_01_09.txt
test_10 subtask_01_10.txt
Case Name Status Exec Time Memory
subtask_01_01.txt AC 1 ms 128 KB
subtask_01_02.txt AC 1 ms 128 KB
subtask_01_03.txt AC 1 ms 128 KB
subtask_01_04.txt AC 1 ms 128 KB
subtask_01_05.txt AC 1 ms 128 KB
subtask_01_06.txt AC 1 ms 128 KB
subtask_01_07.txt AC 1 ms 128 KB
subtask_01_08.txt AC 1 ms 128 KB
subtask_01_09.txt AC 1 ms 128 KB
subtask_01_10.txt AC 1 ms 128 KB