답안 #635781

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
635781 2022-08-26T23:31:00 Z activedeltorre 송신탑 (IOI22_towers) C++17
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <vector>

using namespace std;
int n,cent;
int h[200005];
init (int N, vector<int>vec)
{
    int n=N;
    int i;
    for(i=1;i<=n;i++)
    {
        h[i]=vec[i-1];
        if(h[i]==n)
        {
            cent=i;
        }
    }
}
max_towers(int l,int r,int d)
{
    if(l<=cent && r>=cent && max(h[l],h[r])+d<=n)
    {
        return 2;
    }
    else
    {
        return 1;
    }
}

Compilation message

towers.cpp:7:1: error: ISO C++ forbids declaration of 'init' with no type [-fpermissive]
    7 | init (int N, vector<int>vec)
      | ^~~~
towers.cpp: In function 'int init(int, std::vector<int>)':
towers.cpp:19:1: warning: no return statement in function returning non-void [-Wreturn-type]
   19 | }
      | ^
towers.cpp: At global scope:
towers.cpp:20:1: error: ISO C++ forbids declaration of 'max_towers' with no type [-fpermissive]
   20 | max_towers(int l,int r,int d)
      | ^~~~~~~~~~