Submission #28150

#TimeUsernameProblemLanguageResultExecution timeMemory
28150시.공.조.아. (#71)The City and The Bitcoin (FXCUP2_city)C11
0 / 1
0 ms1468 KiB
#include <stdio.h> #include <stdlib.h> int Box[300][300]; int di[2] = { 0,1}; int dj[2] = { 1,0}; int N, M, result; typedef struct { int row, col; struct ListNode *next; }ListNode; typedef struct { ListNode *front, *rear; int cnt; }Queue; void init(Queue *Q) { Q->front = Q->rear = NULL; Q->cnt = 0; } int Queue_Emtpy(Queue *Q) { if (Q->cnt == 0) return 1; else return 0; } void Enqueue(Queue *Q, int row, int col) { ListNode *temp = (ListNode *)malloc(sizeof(ListNode)); temp->row = row; temp->col = col; temp->next = NULL; if (Queue_Emtpy(Q)) { Q->front = temp; } else { Q->rear->next = temp; } Q->rear = temp; Q->cnt++; } ListNode *Dequeue(Queue *Q) { ListNode *current; current = Q->front; Q->front = current->next; Q->cnt--; return current; } void go(Queue *Q, int i, int j) { int k; for (k = 0; k < 2; k++) { int ni = i + di[k]; int nj = j + dj[k]; if (0 <= nj && nj < M && 0 <= ni && ni < N) { if (Box[ni][nj] == 1){ if (ni == N - 1 && nj == M - 1) { result = 1; break; } else Enqueue(Q, ni, nj); } } } } int main() { int i, j, k = 0, count = 0; Queue Q; ListNode *temp; init(&Q); scanf("%d %d", &M, &N); for (i = 0; i < N; i++) { for (j = 0; j < M; j++) { scanf("%d", &Box[i][j]); if (Box[i][j] == 1) Enqueue(&Q, i, j); } } while (!Queue_Emtpy(&Q)) { temp = Dequeue(&Q); go(&Q, temp->row, temp->col); } if (result == 1) printf("Yes"); else printf("No"); }

Compilation message (stderr)

city.c: In function 'Enqueue':
city.c:45:17: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
   Q->rear->next = temp;
                 ^
city.c: In function 'Dequeue':
city.c:55:11: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
  Q->front = current->next;
           ^
city.c: In function 'main':
city.c:83:19: warning: unused variable 'count' [-Wunused-variable]
  int i, j, k = 0, count = 0;
                   ^
city.c:83:12: warning: unused variable 'k' [-Wunused-variable]
  int i, j, k = 0, count = 0;
            ^
city.c:87:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &M, &N);
  ^
city.c:90:4: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &Box[i][j]);
    ^
#Verdict Execution timeMemoryGrader output
Fetching results...