제출 #888558

#제출 시각아이디문제언어결과실행 시간메모리
888558Gabriel철로 (IOI14_rail)C++17
30 / 100
44 ms604 KiB
#include "rail.h"
#include "bits/stdc++.h"
using namespace std;
void findLocation(int N, int first, int location[], int stype[]){
    int i = 0;
    if(N == 1){
        location[0] = first;
        stype[0] = 1;
        return;
    }
    vector< pair<int, int> > Distancias_desde_el_0;
    pair<int, int> M_nimo = make_pair(INT_MAX, -1);
    while(i < N){
        Distancias_desde_el_0.push_back(make_pair(getDistance(0, i), i));
        if(Distancias_desde_el_0[i].first < M_nimo.first and Distancias_desde_el_0[i].second != 0) M_nimo = Distancias_desde_el_0[i];
        i++;
    }
    memset(location, 0, sizeof(location));
    memset(stype, 0, sizeof(stype));
    location[0] = first;
    stype[0] = 1;
    location[M_nimo.second] = M_nimo.first + first;
    stype[M_nimo.second] = 2;
    i = 0;
    while(i < N){
        if(!(i == M_nimo.second or i == 0)){
            int Distancia = getDistance(M_nimo.second, i);
            int Posible_1 = first + Distancias_desde_el_0[i].first;
            int Posible_2 = first - (Distancias_desde_el_0[i].first - 2 * M_nimo.first);
            int Posible_3 = first + M_nimo.first - Distancia;
            int Posible_4 = first + M_nimo.first + Distancia - 2 * M_nimo.first;
            //cout<<i<<" "<<Posible_1<<" "<<Posible_2<<" "<<Posible_3<<" "<<Posible_4<<"\n";
            if(Posible_1 == Posible_3 or Posible_1 == Posible_4){
                location[i] = Posible_1;
                stype[i] = (int)(location[i] > first) + 1;
            }
            if(Posible_2 == Posible_3 or Posible_2 == Posible_4){
                location[i] = Posible_2;
                stype[i] = (int)(location[i] > first) + 1;
            }
        }
        //cout<<location[i]<<" "<<stype[i]<<"\n";
        i++;
    }
    return;
}

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

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:18:32: warning: 'sizeof' on array function parameter 'location' will return size of 'int*' [-Wsizeof-array-argument]
   18 |     memset(location, 0, sizeof(location));
      |                               ~^~~~~~~~~
rail.cpp:4:41: note: declared here
    4 | void findLocation(int N, int first, int location[], int stype[]){
      |                                     ~~~~^~~~~~~~~~
rail.cpp:18:25: 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]
   18 |     memset(location, 0, sizeof(location));
      |                         ^~~~~~~~~~~~~~~~
rail.cpp:19:29: warning: 'sizeof' on array function parameter 'stype' will return size of 'int*' [-Wsizeof-array-argument]
   19 |     memset(stype, 0, sizeof(stype));
      |                            ~^~~~~~
rail.cpp:4:57: note: declared here
    4 | void findLocation(int N, int first, int location[], int stype[]){
      |                                                     ~~~~^~~~~~~
rail.cpp:19: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]
   19 |     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...