답안 #707582

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
707582 2023-03-09T11:48:14 Z Trisanu_Das Autobus (COCI22_autobus) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

int n, m, k, adj[70][70], dp[70][70][70];

int main(){
  cin >> n >> m;
  memset(adj, INT_MAX, sizeof(adj));
  for(int i = 0; i < n; i++) adj[i][i] = 0;
  while(m--){
    int u, v, w; cin >> u >> v >> w;
    adj[u - 1][v - 1] = min(adj[u - 1][v - 1], w);
  }
  cin >> k >> q;
  k = (k > n - 1) ? n - 1 : k;
  memset(dp, 0x3f, dp);
  for (int i=0; i<n; ++i)
		for (int j=0; j<n; ++j) {
			dp[0][i][j]=i==j?0:INF;
			dp[1][i][j]=d[i][j];
		}
  for(int i = 2; i < k + 1; i++) for(int u = 0; u < n; u++) for(int u2 = 0; u2 < n; u2++) for(int v = 0; v < n; v++) dp[i][u][v] = min(dp[i][u][v], dp[i - 1][u][u2] + adj[u2][v]);
  while(q--){
    int u, v; cin >> u >> v;
    cout << (dp[k][u][v] >= (int)1e9) ? -1 : dp[k][u][v] << '\n';
  }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:14:15: error: 'q' was not declared in this scope
   14 |   cin >> k >> q;
      |               ^
Main.cpp:16:20: error: invalid conversion from 'int (*)[70][70]' to 'size_t' {aka 'long unsigned int'} [-fpermissive]
   16 |   memset(dp, 0x3f, dp);
      |                    ^~
      |                    |
      |                    int (*)[70][70]
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from Main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:1: note:   initializing argument 3 of 'void* memset(void*, int, size_t)'
   59 | __NTH (memset (void *__dest, int __ch, size_t __len))
      | ^~~~~
Main.cpp:19:23: error: 'INF' was not declared in this scope
   19 |    dp[0][i][j]=i==j?0:INF;
      |                       ^~~
Main.cpp:20:16: error: 'd' was not declared in this scope
   20 |    dp[1][i][j]=d[i][j];
      |                ^
Main.cpp:25:65: warning: second operand of conditional expression has no effect [-Wunused-value]
   25 |     cout << (dp[k][u][v] >= (int)1e9) ? -1 : dp[k][u][v] << '\n';
      |                                                                 ^
Main.cpp:25:58: warning: third operand of conditional expression has no effect [-Wunused-value]
   25 |     cout << (dp[k][u][v] >= (int)1e9) ? -1 : dp[k][u][v] << '\n';
      |                                              ~~~~~~~~~~~~^~~~~~~