제출 #398061

#제출 시각아이디문제언어결과실행 시간메모리
398061phathnv철로 (IOI14_rail)C++11
30 / 100
489 ms98524 KiB
#include <bits/stdc++.h>
#include "rail.h"

using namespace std;

const int N = 5000;

int dist[N][N];
vector<int> adj[N];

void Dfs(int u, int type, int location[], int stype[]){
    assert(stype[u] != 3 - type);
    if (stype[u])
        return;
    stype[u] = type;
    for(int v : adj[u]){
        location[v] = location[u] + (type == 1? dist[u][v] : -dist[u][v]);
        Dfs(v, 3 - type, location, stype);
    }
}

void findLocation(int n, int first, int location[], int stype[]){
    for(int i = 0; i < n; i++){
        dist[i][i] = 1e9;
        for(int j = i + 1; j <= n; j++)
            dist[i][j] = dist[j][i] = getDistance(i, j);
    }
    for(int u = 0; u < n; u++){
        int v = 0;
        for(int i = 0; i < n; i++)
            if (dist[u][v] > dist[u][i])
                v = i;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    memset(stype, 0, sizeof(stype));
    location[0] = first;
    Dfs(0, 1, location, stype);
}

컴파일 시 표준 에러 (stderr) 메시지

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:36:34: warning: 'sizeof' on array function parameter 'stype' will return size of 'int*' [-Wsizeof-array-argument]
   36 |     memset(stype, 0, sizeof(stype));
      |                                  ^
rail.cpp:22:57: note: declared here
   22 | void findLocation(int n, int first, int location[], int stype[]){
      |                                                     ~~~~^~~~~~~
rail.cpp:36:22: warning: argument to 'sizeof' in 'void* memset(void*, int, size_t)' call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
   36 |     memset(stype, 0, sizeof(stype));
      |                      ^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...