답안 #200979

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
200979 2020-02-09T02:27:23 Z model_code Političari (COCI20_politicari) C++17
35 / 70
1000 ms 1400 KB
#include <bits/stdc++.h>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

typedef long long llint;

const int MAXN = 505;

int n, k;
int mat[MAXN][MAXN];

int main(void) {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      scanf("%d", &mat[i][j]);

  if (k < 3) {
    printf("%d\n", k);
    return 0;
  }

  int prev = 0;
  int curr = 1;

  for (int i = 0; i < k - 2; ++i) {
    int nxt = mat[curr][prev] - 1;
    prev = curr;
    curr = nxt;
  }

  printf("%d\n", curr + 1);
  return 0;
}

Compilation message

politicari.cpp: In function 'int main()':
politicari.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &n, &k);
   ~~~~~^~~~~~~~~~~~~~~~
politicari.cpp:21:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d", &mat[i][j]);
       ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Execution timed out 1095 ms 760 KB Time limit exceeded
3 Incorrect 26 ms 1144 KB Output isn't correct
4 Incorrect 32 ms 1144 KB Output isn't correct
5 Incorrect 38 ms 1272 KB Output isn't correct
6 Incorrect 41 ms 1400 KB Output isn't correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 7 ms 632 KB Output is correct
9 Correct 12 ms 760 KB Output is correct
10 Correct 32 ms 1144 KB Output is correct
11 Correct 42 ms 1272 KB Output is correct
12 Correct 39 ms 1272 KB Output is correct
13 Execution timed out 1095 ms 376 KB Time limit exceeded
14 Execution timed out 1093 ms 632 KB Time limit exceeded