답안 #817036

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
817036 2023-08-09T08:44:21 Z finn__ 송신탑 (IOI22_towers) C++17
0 / 100
430 ms 1460 KB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;

constexpr size_t N = 100000;

int subtask, h[N];
size_t peak_pos;

void init(int n, vector<int> h_)
{
    copy(h_.begin(), h_.end(), h);
    bool increasing = 1;
    subtask = 1;
    for (size_t i = 0; i + 1 < n; ++i)
    {
        if (h[i] < h[i + 1] && !increasing)
        {
            subtask = 2;
            break;
        }
        if (h[i] > h[i + 1])
            increasing = 0;
    }

    if (subtask == 1)
    {
        while (peak_pos + 1 < n && h[peak_pos + 1] > h[peak_pos])
            ++peak_pos;
        return;
    }
}

int max_towers(int l, int r, int d)
{
    if (subtask == 1)
    {
        if (l >= peak_pos || r <= peak_pos)
            return 0;
        return h[peak_pos] >= h[l] + d && h[peak_pos] >= h[r] + d;
    }
}

Compilation message

towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:15:30: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |     for (size_t i = 0; i + 1 < n; ++i)
      |                        ~~~~~~^~~
towers.cpp:28:29: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |         while (peak_pos + 1 < n && h[peak_pos + 1] > h[peak_pos])
      |                ~~~~~~~~~~~~~^~~
towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         if (l >= peak_pos || r <= peak_pos)
      |             ~~^~~~~~~~~~~
towers.cpp:38:32: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         if (l >= peak_pos || r <= peak_pos)
      |                              ~~^~~~~~~~~~~
towers.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
   42 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 317 ms 936 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 430 ms 1460 KB 1st lines differ - on the 1st token, expected: '11903', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 172 ms 464 KB 1st lines differ - on the 1st token, expected: '7197', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 317 ms 936 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -