답안 #780348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
780348 2023-07-12T08:24:40 Z boris_mihov Maze (JOI23_ho_t3) C++17
43 / 100
1491 ms 993680 KB
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
#include <queue>

typedef long long llong;
const int MAXLOG = 23;
const int MAXN = 6000000 + 10;
const int INF  = 1e9;

const int BUFF_SIZE = 1e6;
char buff[BUFF_SIZE];
int buffPos = BUFF_SIZE-1;

inline void readChar() 
{
    if (++buffPos == BUFF_SIZE) fread(buff, BUFF_SIZE, 1, stdin), buffPos = 0;
}

inline void readInt(int &num) 
{
    num = 0;
    for (; '0' > buff[buffPos] || buff[buffPos] > '9' ; readChar());
    for (; '0' <= buff[buffPos] && buff[buffPos] <= '9' ; readChar())
    {
        num = 10*num + buff[buffPos]-'0';
    }
}

void readString(std::string &s)
{
    s[0] = ' ';
    int pos = 1;
    for (; buff[buffPos] != '#' && buff[buffPos] != '.' ; readChar());
    for (; buff[buffPos] == '#' || buff[buffPos] == '.' ; readChar())
    {
        s[pos++] = buff[buffPos];
    }
}

struct BIT
{
    std::vector <int> tree;
    void build(int sz)
    {
        tree.resize(sz + 1, 0);
    }

    void update(int pos, int value)
    {
        assert(pos >= 1 && pos < (int)tree.size());
        for (int idx = pos ; idx < (int)tree.size() ; idx += idx & (-idx))
        {
            tree[idx] += value;
        }
    }

    int query(int pos)
    {
        assert(pos >= 0 && pos < (int)tree.size());
        int res = 0;
        for (int idx = pos ; idx > 0 ; idx -= idx & (-idx))
        {
            res += tree[idx];
        }

        return pos - res;
    }

    int findKth(int k)
    {
        int idx = 0;
        for (int log = MAXLOG - 1 ; log >= 0 ; --log)
        {
            if (idx + (1 << log) < (int)tree.size() && (1 << log) - tree[idx + (1 << log)] < k)
            {
                idx += (1 << log);
                k -= (1 << log) - tree[idx];
            }
        }

        return idx + 1;
    }
};

int r, c, n;
int sRow, sCol;
int eRow, eCol;
BIT byROW[MAXN];
BIT byCOL[MAXN];
std::pair <int,int> delta[] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};
std::deque <std::pair <int,int>> dq;
std::vector <int> dist[MAXN];
std::string t[MAXN];

bool isOutside(int row, int col)
{
    return row == 0 || row == r + 1 || col == 0 || col == c + 1;
}

void setCELL(int row, int col)
{
    if (dist[row][col] == INF)
    {
        byROW[row].update(col, 1); 
        byCOL[col].update(row, 1); 
    }
}

void addROW(int row, int colL, int colR, int currDist)
{
    int curr = byROW[row].query(colL - 1);
    while (curr < byROW[row].query(c))
    {
        int search = byROW[row].findKth(curr + 1);
        if (search > colR)
        {
            break;
        }

        setCELL(row, search);
        if (dist[row][search] > currDist + 1) dist[row][search] = currDist + 1;
        dq.push_back({row, search});
    }
}

void addCOL(int col, int rowL, int rowR, int currDist)
{
    int curr = byCOL[col].query(rowL - 1);
    while (curr < byCOL[col].query(r))
    {
        int search = byCOL[col].findKth(curr + 1);
        if (search > rowR)
        {
            break;
        }

        setCELL(search, col);
        if (dist[search][col] > currDist + 1) dist[search][col] = currDist + 1;
        dq.push_back({search, col});
    }
}

void solve()
{
    for (int i = 1 ; i <= r ; ++i)
    {
        std::fill(dist[i].begin(), dist[i].end(), INF);
    }

    for (int i = 1 ; i <= r ; ++i)
    {
        byROW[i].build(c);
    }
    
    for (int i = 1 ; i <= c ; ++i)
    {
        byCOL[i].build(r);
    }
    
    setCELL(sRow, sCol);
    dq.push_back({sRow, sCol});
    dist[sRow][sCol] = 0;

    while (!dq.empty())
    {
        auto [row, col] = dq.front();
        dq.pop_front();    

        if (row == eRow && col == eCol)
        {
            std::cout << dist[row][col] << '\n';
            break;
        }

        for (const auto &[dx, dy] : delta)
        {
            if (isOutside(row + dx, col + dy) || dist[row + dx][col + dy] <= dist[row][col])
            {
                continue;
            }

            if (t[row + dx][col + dy] == '.')
            {
                setCELL(row + dx, col + dy);
                dist[row + dx][col + dy] = dist[row][col]; 
                dq.push_front({row + dx, col + dy});
            }
        }

        if (abs(row - eRow) <= n && abs(col - eCol) <= n && dist[eRow][eCol] > dist[row][col])
        {
            setCELL(eRow, eCol);
            dist[eRow][eCol] = dist[row][col] + 1;
            dq.push_back({eRow, eCol});
        }

        addROW(std::max(1, row - n), std::max(1, col - n + 1), std::min(c, col + n - 1), dist[row][col]);
        addROW(std::min(r, row + n), std::max(1, col - n + 1), std::min(c, col + n - 1), dist[row][col]);
        addCOL(std::max(1, col - n), std::max(1, row - n + 1), std::min(r, row + n - 1), dist[row][col]);
        addCOL(std::min(c, col + n), std::max(1, row - n + 1), std::min(r, row + n - 1), dist[row][col]);
    }
}

void input()
{
    readInt(r);
    readInt(c);
    readInt(n);
    readInt(sRow);
    readInt(sCol);
    readInt(eRow);
    readInt(eCol);
    for (int i = 1 ; i <= r ; ++i)
    {
        t[i].resize(c + 1);
        readString(t[i]);
        std::cin >> t[i];
        dist[i].resize(c + 1, INF);
    }
}

void fastIOI()
{
    std::ios_base :: sync_with_stdio(0);
    std::cout.tie(nullptr);
    std::cin.tie(nullptr);
}

int main()
{
    fastIOI();
    input();
    solve();

    return 0;
}

Compilation message

Main.cpp: In function 'void readChar()':
Main.cpp:19:38: warning: ignoring return value of 'size_t fread(void*, size_t, size_t, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     if (++buffPos == BUFF_SIZE) fread(buff, BUFF_SIZE, 1, stdin), buffPos = 0;
      |                                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 251 ms 610868 KB Output is correct
2 Correct 251 ms 610760 KB Output is correct
3 Correct 248 ms 610892 KB Output is correct
4 Correct 244 ms 610840 KB Output is correct
5 Correct 245 ms 610872 KB Output is correct
6 Correct 249 ms 610856 KB Output is correct
7 Correct 249 ms 610972 KB Output is correct
8 Correct 250 ms 610912 KB Output is correct
9 Correct 244 ms 610760 KB Output is correct
10 Correct 260 ms 610884 KB Output is correct
11 Correct 245 ms 610764 KB Output is correct
12 Correct 299 ms 610832 KB Output is correct
13 Correct 252 ms 610824 KB Output is correct
14 Correct 253 ms 610840 KB Output is correct
15 Correct 266 ms 610764 KB Output is correct
16 Correct 254 ms 610840 KB Output is correct
17 Correct 268 ms 610884 KB Output is correct
18 Correct 248 ms 610864 KB Output is correct
19 Correct 260 ms 611664 KB Output is correct
20 Correct 260 ms 612772 KB Output is correct
21 Correct 265 ms 611960 KB Output is correct
22 Correct 272 ms 611608 KB Output is correct
23 Correct 262 ms 611656 KB Output is correct
24 Correct 265 ms 613240 KB Output is correct
25 Correct 267 ms 613272 KB Output is correct
26 Correct 250 ms 611724 KB Output is correct
27 Correct 255 ms 611712 KB Output is correct
28 Correct 258 ms 611648 KB Output is correct
29 Correct 294 ms 612960 KB Output is correct
30 Correct 262 ms 612436 KB Output is correct
31 Correct 258 ms 613152 KB Output is correct
32 Correct 289 ms 612972 KB Output is correct
33 Correct 300 ms 612960 KB Output is correct
34 Correct 292 ms 617020 KB Output is correct
35 Correct 291 ms 617032 KB Output is correct
36 Correct 271 ms 612940 KB Output is correct
37 Correct 280 ms 612992 KB Output is correct
38 Correct 252 ms 612876 KB Output is correct
39 Incorrect 805 ms 631012 KB Output isn't correct
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 258 ms 610896 KB Output is correct
2 Correct 251 ms 610884 KB Output is correct
3 Correct 280 ms 610836 KB Output is correct
4 Correct 245 ms 610796 KB Output is correct
5 Correct 251 ms 610836 KB Output is correct
6 Correct 264 ms 610808 KB Output is correct
7 Correct 252 ms 610848 KB Output is correct
8 Correct 263 ms 610880 KB Output is correct
9 Correct 262 ms 610888 KB Output is correct
10 Correct 249 ms 610884 KB Output is correct
11 Correct 273 ms 610888 KB Output is correct
12 Correct 247 ms 610896 KB Output is correct
13 Correct 252 ms 610888 KB Output is correct
14 Correct 275 ms 610860 KB Output is correct
15 Correct 256 ms 610892 KB Output is correct
16 Correct 250 ms 610912 KB Output is correct
17 Correct 253 ms 610848 KB Output is correct
18 Correct 250 ms 610780 KB Output is correct
19 Correct 272 ms 610792 KB Output is correct
20 Correct 249 ms 610884 KB Output is correct
21 Correct 248 ms 610876 KB Output is correct
22 Correct 248 ms 610836 KB Output is correct
23 Correct 251 ms 610876 KB Output is correct
24 Correct 278 ms 610868 KB Output is correct
25 Correct 251 ms 610776 KB Output is correct
26 Correct 269 ms 610872 KB Output is correct
27 Correct 248 ms 610852 KB Output is correct
28 Correct 257 ms 610884 KB Output is correct
29 Correct 253 ms 610824 KB Output is correct
30 Correct 249 ms 610888 KB Output is correct
31 Correct 251 ms 610764 KB Output is correct
32 Correct 246 ms 610764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 258 ms 610824 KB Output is correct
2 Correct 256 ms 610872 KB Output is correct
3 Correct 250 ms 610796 KB Output is correct
4 Correct 252 ms 611064 KB Output is correct
5 Correct 250 ms 610760 KB Output is correct
6 Correct 256 ms 610840 KB Output is correct
7 Correct 255 ms 610800 KB Output is correct
8 Correct 264 ms 610884 KB Output is correct
9 Correct 250 ms 610872 KB Output is correct
10 Correct 248 ms 610892 KB Output is correct
11 Correct 248 ms 610884 KB Output is correct
12 Correct 247 ms 610912 KB Output is correct
13 Correct 279 ms 610764 KB Output is correct
14 Correct 247 ms 610884 KB Output is correct
15 Correct 251 ms 610872 KB Output is correct
16 Correct 292 ms 610872 KB Output is correct
17 Correct 246 ms 610880 KB Output is correct
18 Correct 287 ms 610872 KB Output is correct
19 Correct 246 ms 610768 KB Output is correct
20 Correct 248 ms 610804 KB Output is correct
21 Correct 255 ms 610812 KB Output is correct
22 Correct 250 ms 610796 KB Output is correct
23 Correct 252 ms 610888 KB Output is correct
24 Correct 250 ms 610792 KB Output is correct
25 Correct 253 ms 611304 KB Output is correct
26 Correct 259 ms 611940 KB Output is correct
27 Correct 258 ms 611964 KB Output is correct
28 Correct 248 ms 611764 KB Output is correct
29 Correct 259 ms 611676 KB Output is correct
30 Correct 247 ms 611696 KB Output is correct
31 Correct 284 ms 611792 KB Output is correct
32 Correct 263 ms 611720 KB Output is correct
33 Correct 247 ms 611624 KB Output is correct
34 Correct 277 ms 613704 KB Output is correct
35 Correct 260 ms 613172 KB Output is correct
36 Correct 258 ms 613592 KB Output is correct
37 Correct 266 ms 612964 KB Output is correct
38 Correct 286 ms 612920 KB Output is correct
39 Correct 332 ms 620888 KB Output is correct
40 Runtime error 1491 ms 993680 KB Execution killed with signal 6
41 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 258 ms 610896 KB Output is correct
2 Correct 251 ms 610884 KB Output is correct
3 Correct 280 ms 610836 KB Output is correct
4 Correct 245 ms 610796 KB Output is correct
5 Correct 251 ms 610836 KB Output is correct
6 Correct 264 ms 610808 KB Output is correct
7 Correct 252 ms 610848 KB Output is correct
8 Correct 263 ms 610880 KB Output is correct
9 Correct 262 ms 610888 KB Output is correct
10 Correct 249 ms 610884 KB Output is correct
11 Correct 273 ms 610888 KB Output is correct
12 Correct 247 ms 610896 KB Output is correct
13 Correct 252 ms 610888 KB Output is correct
14 Correct 275 ms 610860 KB Output is correct
15 Correct 256 ms 610892 KB Output is correct
16 Correct 250 ms 610912 KB Output is correct
17 Correct 253 ms 610848 KB Output is correct
18 Correct 250 ms 610780 KB Output is correct
19 Correct 272 ms 610792 KB Output is correct
20 Correct 249 ms 610884 KB Output is correct
21 Correct 248 ms 610876 KB Output is correct
22 Correct 248 ms 610836 KB Output is correct
23 Correct 251 ms 610876 KB Output is correct
24 Correct 278 ms 610868 KB Output is correct
25 Correct 251 ms 610776 KB Output is correct
26 Correct 269 ms 610872 KB Output is correct
27 Correct 248 ms 610852 KB Output is correct
28 Correct 257 ms 610884 KB Output is correct
29 Correct 253 ms 610824 KB Output is correct
30 Correct 249 ms 610888 KB Output is correct
31 Correct 251 ms 610764 KB Output is correct
32 Correct 246 ms 610764 KB Output is correct
33 Correct 328 ms 611768 KB Output is correct
34 Correct 283 ms 610872 KB Output is correct
35 Correct 270 ms 610996 KB Output is correct
36 Correct 300 ms 611388 KB Output is correct
37 Correct 283 ms 612832 KB Output is correct
38 Correct 316 ms 612036 KB Output is correct
39 Correct 299 ms 611924 KB Output is correct
40 Correct 297 ms 611700 KB Output is correct
41 Correct 308 ms 611736 KB Output is correct
42 Correct 305 ms 611708 KB Output is correct
43 Correct 313 ms 611676 KB Output is correct
44 Correct 298 ms 611776 KB Output is correct
45 Correct 286 ms 613412 KB Output is correct
46 Correct 286 ms 613312 KB Output is correct
47 Correct 270 ms 612336 KB Output is correct
48 Correct 307 ms 611836 KB Output is correct
49 Correct 274 ms 611812 KB Output is correct
50 Correct 281 ms 611800 KB Output is correct
51 Correct 290 ms 611916 KB Output is correct
52 Correct 287 ms 611780 KB Output is correct
53 Correct 274 ms 611648 KB Output is correct
54 Correct 288 ms 611700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 258 ms 610896 KB Output is correct
2 Correct 251 ms 610884 KB Output is correct
3 Correct 280 ms 610836 KB Output is correct
4 Correct 245 ms 610796 KB Output is correct
5 Correct 251 ms 610836 KB Output is correct
6 Correct 264 ms 610808 KB Output is correct
7 Correct 252 ms 610848 KB Output is correct
8 Correct 263 ms 610880 KB Output is correct
9 Correct 262 ms 610888 KB Output is correct
10 Correct 249 ms 610884 KB Output is correct
11 Correct 273 ms 610888 KB Output is correct
12 Correct 247 ms 610896 KB Output is correct
13 Correct 252 ms 610888 KB Output is correct
14 Correct 275 ms 610860 KB Output is correct
15 Correct 256 ms 610892 KB Output is correct
16 Correct 250 ms 610912 KB Output is correct
17 Correct 253 ms 610848 KB Output is correct
18 Correct 250 ms 610780 KB Output is correct
19 Correct 272 ms 610792 KB Output is correct
20 Correct 249 ms 610884 KB Output is correct
21 Correct 248 ms 610876 KB Output is correct
22 Correct 248 ms 610836 KB Output is correct
23 Correct 251 ms 610876 KB Output is correct
24 Correct 278 ms 610868 KB Output is correct
25 Correct 251 ms 610776 KB Output is correct
26 Correct 269 ms 610872 KB Output is correct
27 Correct 248 ms 610852 KB Output is correct
28 Correct 257 ms 610884 KB Output is correct
29 Correct 253 ms 610824 KB Output is correct
30 Correct 249 ms 610888 KB Output is correct
31 Correct 251 ms 610764 KB Output is correct
32 Correct 246 ms 610764 KB Output is correct
33 Correct 328 ms 611768 KB Output is correct
34 Correct 283 ms 610872 KB Output is correct
35 Correct 270 ms 610996 KB Output is correct
36 Correct 300 ms 611388 KB Output is correct
37 Correct 283 ms 612832 KB Output is correct
38 Correct 316 ms 612036 KB Output is correct
39 Correct 299 ms 611924 KB Output is correct
40 Correct 297 ms 611700 KB Output is correct
41 Correct 308 ms 611736 KB Output is correct
42 Correct 305 ms 611708 KB Output is correct
43 Correct 313 ms 611676 KB Output is correct
44 Correct 298 ms 611776 KB Output is correct
45 Correct 286 ms 613412 KB Output is correct
46 Correct 286 ms 613312 KB Output is correct
47 Correct 270 ms 612336 KB Output is correct
48 Correct 307 ms 611836 KB Output is correct
49 Correct 274 ms 611812 KB Output is correct
50 Correct 281 ms 611800 KB Output is correct
51 Correct 290 ms 611916 KB Output is correct
52 Correct 287 ms 611780 KB Output is correct
53 Correct 274 ms 611648 KB Output is correct
54 Correct 288 ms 611700 KB Output is correct
55 Correct 309 ms 613088 KB Output is correct
56 Correct 289 ms 612464 KB Output is correct
57 Correct 284 ms 613836 KB Output is correct
58 Correct 305 ms 612920 KB Output is correct
59 Correct 308 ms 613288 KB Output is correct
60 Correct 321 ms 613064 KB Output is correct
61 Correct 313 ms 613084 KB Output is correct
62 Correct 312 ms 613752 KB Output is correct
63 Correct 271 ms 613096 KB Output is correct
64 Correct 275 ms 613048 KB Output is correct
65 Correct 321 ms 617200 KB Output is correct
66 Correct 305 ms 617180 KB Output is correct
67 Correct 300 ms 614840 KB Output is correct
68 Correct 280 ms 613160 KB Output is correct
69 Correct 299 ms 613096 KB Output is correct
70 Correct 288 ms 613204 KB Output is correct
71 Correct 290 ms 613312 KB Output is correct
72 Correct 292 ms 613140 KB Output is correct
73 Correct 337 ms 613116 KB Output is correct
74 Correct 270 ms 613080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 251 ms 610868 KB Output is correct
2 Correct 251 ms 610760 KB Output is correct
3 Correct 248 ms 610892 KB Output is correct
4 Correct 244 ms 610840 KB Output is correct
5 Correct 245 ms 610872 KB Output is correct
6 Correct 249 ms 610856 KB Output is correct
7 Correct 249 ms 610972 KB Output is correct
8 Correct 250 ms 610912 KB Output is correct
9 Correct 244 ms 610760 KB Output is correct
10 Correct 260 ms 610884 KB Output is correct
11 Correct 245 ms 610764 KB Output is correct
12 Correct 299 ms 610832 KB Output is correct
13 Correct 252 ms 610824 KB Output is correct
14 Correct 253 ms 610840 KB Output is correct
15 Correct 266 ms 610764 KB Output is correct
16 Correct 254 ms 610840 KB Output is correct
17 Correct 268 ms 610884 KB Output is correct
18 Correct 248 ms 610864 KB Output is correct
19 Correct 260 ms 611664 KB Output is correct
20 Correct 260 ms 612772 KB Output is correct
21 Correct 265 ms 611960 KB Output is correct
22 Correct 272 ms 611608 KB Output is correct
23 Correct 262 ms 611656 KB Output is correct
24 Correct 265 ms 613240 KB Output is correct
25 Correct 267 ms 613272 KB Output is correct
26 Correct 250 ms 611724 KB Output is correct
27 Correct 255 ms 611712 KB Output is correct
28 Correct 258 ms 611648 KB Output is correct
29 Correct 294 ms 612960 KB Output is correct
30 Correct 262 ms 612436 KB Output is correct
31 Correct 258 ms 613152 KB Output is correct
32 Correct 289 ms 612972 KB Output is correct
33 Correct 300 ms 612960 KB Output is correct
34 Correct 292 ms 617020 KB Output is correct
35 Correct 291 ms 617032 KB Output is correct
36 Correct 271 ms 612940 KB Output is correct
37 Correct 280 ms 612992 KB Output is correct
38 Correct 252 ms 612876 KB Output is correct
39 Incorrect 805 ms 631012 KB Output isn't correct
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 251 ms 610868 KB Output is correct
2 Correct 251 ms 610760 KB Output is correct
3 Correct 248 ms 610892 KB Output is correct
4 Correct 244 ms 610840 KB Output is correct
5 Correct 245 ms 610872 KB Output is correct
6 Correct 249 ms 610856 KB Output is correct
7 Correct 249 ms 610972 KB Output is correct
8 Correct 250 ms 610912 KB Output is correct
9 Correct 244 ms 610760 KB Output is correct
10 Correct 260 ms 610884 KB Output is correct
11 Correct 245 ms 610764 KB Output is correct
12 Correct 299 ms 610832 KB Output is correct
13 Correct 252 ms 610824 KB Output is correct
14 Correct 253 ms 610840 KB Output is correct
15 Correct 266 ms 610764 KB Output is correct
16 Correct 254 ms 610840 KB Output is correct
17 Correct 268 ms 610884 KB Output is correct
18 Correct 248 ms 610864 KB Output is correct
19 Correct 260 ms 611664 KB Output is correct
20 Correct 260 ms 612772 KB Output is correct
21 Correct 265 ms 611960 KB Output is correct
22 Correct 272 ms 611608 KB Output is correct
23 Correct 262 ms 611656 KB Output is correct
24 Correct 265 ms 613240 KB Output is correct
25 Correct 267 ms 613272 KB Output is correct
26 Correct 250 ms 611724 KB Output is correct
27 Correct 255 ms 611712 KB Output is correct
28 Correct 258 ms 611648 KB Output is correct
29 Correct 294 ms 612960 KB Output is correct
30 Correct 262 ms 612436 KB Output is correct
31 Correct 258 ms 613152 KB Output is correct
32 Correct 289 ms 612972 KB Output is correct
33 Correct 300 ms 612960 KB Output is correct
34 Correct 292 ms 617020 KB Output is correct
35 Correct 291 ms 617032 KB Output is correct
36 Correct 271 ms 612940 KB Output is correct
37 Correct 280 ms 612992 KB Output is correct
38 Correct 252 ms 612876 KB Output is correct
39 Incorrect 805 ms 631012 KB Output isn't correct
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 251 ms 610868 KB Output is correct
2 Correct 251 ms 610760 KB Output is correct
3 Correct 248 ms 610892 KB Output is correct
4 Correct 244 ms 610840 KB Output is correct
5 Correct 245 ms 610872 KB Output is correct
6 Correct 249 ms 610856 KB Output is correct
7 Correct 249 ms 610972 KB Output is correct
8 Correct 250 ms 610912 KB Output is correct
9 Correct 244 ms 610760 KB Output is correct
10 Correct 260 ms 610884 KB Output is correct
11 Correct 245 ms 610764 KB Output is correct
12 Correct 299 ms 610832 KB Output is correct
13 Correct 252 ms 610824 KB Output is correct
14 Correct 253 ms 610840 KB Output is correct
15 Correct 266 ms 610764 KB Output is correct
16 Correct 254 ms 610840 KB Output is correct
17 Correct 268 ms 610884 KB Output is correct
18 Correct 248 ms 610864 KB Output is correct
19 Correct 260 ms 611664 KB Output is correct
20 Correct 260 ms 612772 KB Output is correct
21 Correct 265 ms 611960 KB Output is correct
22 Correct 272 ms 611608 KB Output is correct
23 Correct 262 ms 611656 KB Output is correct
24 Correct 265 ms 613240 KB Output is correct
25 Correct 267 ms 613272 KB Output is correct
26 Correct 250 ms 611724 KB Output is correct
27 Correct 255 ms 611712 KB Output is correct
28 Correct 258 ms 611648 KB Output is correct
29 Correct 294 ms 612960 KB Output is correct
30 Correct 262 ms 612436 KB Output is correct
31 Correct 258 ms 613152 KB Output is correct
32 Correct 289 ms 612972 KB Output is correct
33 Correct 300 ms 612960 KB Output is correct
34 Correct 292 ms 617020 KB Output is correct
35 Correct 291 ms 617032 KB Output is correct
36 Correct 271 ms 612940 KB Output is correct
37 Correct 280 ms 612992 KB Output is correct
38 Correct 252 ms 612876 KB Output is correct
39 Incorrect 805 ms 631012 KB Output isn't correct
40 Halted 0 ms 0 KB -