Submission #817039

# Submission time Handle Problem Language Result Execution time Memory
817039 2023-08-09T08:44:52 Z finn__ Radio Towers (IOI22_towers) C++17
4 / 100
693 ms 1452 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 1;
        return (h[peak_pos] >= h[l] + d && h[peak_pos] >= h[r] + d) + 1;
    }
}

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 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 355 ms 944 KB Output is correct
2 Correct 590 ms 1432 KB Output is correct
3 Correct 626 ms 1452 KB Output is correct
4 Correct 630 ms 1440 KB Output is correct
5 Correct 589 ms 1360 KB Output is correct
6 Correct 693 ms 1440 KB Output is correct
7 Correct 613 ms 1432 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 455 ms 1332 KB 1st lines differ - on the 1st token, expected: '11903', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 205 ms 464 KB 1st lines differ - on the 1st token, expected: '7197', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 355 ms 944 KB Output is correct
2 Correct 590 ms 1432 KB Output is correct
3 Correct 626 ms 1452 KB Output is correct
4 Correct 630 ms 1440 KB Output is correct
5 Correct 589 ms 1360 KB Output is correct
6 Correct 693 ms 1440 KB Output is correct
7 Correct 613 ms 1432 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '1'
12 Halted 0 ms 0 KB -