답안 #133869

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
133869 2019-07-21T15:48:35 Z Kastanda UFO (IZhO14_ufo) C++11
15 / 100
482 ms 239632 KB
// ItnoE
#include<bits/stdc++.h>
#define lc (id << 1)
#define rc (lc ^ 1)
#define md (l + r >> 1)
using namespace std;
int R, ts, val, ii, ret[11];
struct Tree
{
    int N, * MX;
    inline Tree(int _N = 0)
    {
        N = _N;
        MX = new int [N + 3 << 1];
    }
    inline void Setter(int _ii, int _val)
    {
        ii = _ii;
        val = _val;
        Set(1, 1, N + 1);
    }
    inline void Getter(int _val, int d)
    {
        ts = 0;
        val = _val;
        if (d == 0)
            GetPref(1, 1, N + 1);
        else
            GetSuff(1, 1, N + 1);
    }
    void Set(int id, int l, int r)
    {
        if (r - l < 2)
            return void(MX[id] = val);
        if (ii < md)
            Set(lc, l, md);
        else
            Set(rc, md, r);
        MX[id] = max(MX[lc], MX[rc]);
    }
    void GetPref(int id, int l, int r)
    {
        if (MX[id] < val || ts >= R)
            return ;
        if (r - l < 2)
            return void(ret[ts ++] = l);
        GetPref(lc, l, md);
        GetPref(rc, md, r);
    }
    void GetSuff(int id, int l, int r)
    {
        if (MX[id] < val || ts >= R)
            return ;
        if (r - l < 2)
            return void(ret[ts ++] = l);
        GetSuff(rc, md, r);
        GetSuff(lc, l, md);
    }
};
int main()
{
    int n, m, q, p;
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> m >> R >> q >> p;
    int A[n + 3][m + 3];
    memset(A, 0, sizeof(A));
    for (int i = 1; i <= n; i ++)
        for (int j = 1; j <= m; j ++)
            cin >> A[i][j];
    Tree rows[n + 3], cols[m + 3];
    for (int i = 1; i <= n; i ++)
        rows[i] = Tree(m);
    for (int i = 1; i <= m; i ++)
        cols[i] = Tree(n);
    for (int i = 1; i <= n; i ++)
        for (int j = 1; j <= m; j ++)
        {
            rows[i].Setter(j, A[i][j]);
            cols[j].Setter(i, A[i][j]);
        }
    for (; q; q --)
    {
        char ch;
        int id, h;
        cin >> ch >> id >> h;
        if (ch == 'W' || ch == 'E')
        {
            rows[id].Getter(h, ch == 'E');
            for (int i = 0; i < ts; i ++)
            {
                A[id][ret[i]] --;
                rows[id].Setter(ret[i], A[id][ret[i]]);
                cols[ret[i]].Setter(id, A[id][ret[i]]);
            }
        }
        else
        {
            cols[id].Getter(h, ch == 'S');
            for (int i = 0; i < ts; i ++)
            {
                A[ret[i]][id] --;
                rows[ret[i]].Setter(id, A[ret[i]][id]);
                cols[id].Setter(ret[i], A[ret[i]][id]);
            }
        }
    }
    int Mx = 0;
    for (int i = p; i <= n; i ++)
        for (int j = p; j <= m; j ++)
        {
            int SM = 0;
            for (int a = i - p + 1; a <= i; a ++)
                for (int b = j - p + 1; b <= j; b ++)
                    SM += A[a][b];
            Mx = max(Mx, SM);
        }
    return !printf("%d\n", Mx);
}

Compilation message

ufo.cpp: In constructor 'Tree::Tree(int)':
ufo.cpp:14:25: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
         MX = new int [N + 3 << 1];
                       ~~^~~
ufo.cpp: In member function 'void Tree::Set(int, int, int)':
ufo.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define md (l + r >> 1)
             ~~^~~
ufo.cpp:35:18: note: in expansion of macro 'md'
         if (ii < md)
                  ^~
ufo.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define md (l + r >> 1)
             ~~^~~
ufo.cpp:36:24: note: in expansion of macro 'md'
             Set(lc, l, md);
                        ^~
ufo.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define md (l + r >> 1)
             ~~^~~
ufo.cpp:38:21: note: in expansion of macro 'md'
             Set(rc, md, r);
                     ^~
ufo.cpp: In member function 'void Tree::GetPref(int, int, int)':
ufo.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define md (l + r >> 1)
             ~~^~~
ufo.cpp:47:24: note: in expansion of macro 'md'
         GetPref(lc, l, md);
                        ^~
ufo.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define md (l + r >> 1)
             ~~^~~
ufo.cpp:48:21: note: in expansion of macro 'md'
         GetPref(rc, md, r);
                     ^~
ufo.cpp: In member function 'void Tree::GetSuff(int, int, int)':
ufo.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define md (l + r >> 1)
             ~~^~~
ufo.cpp:56:21: note: in expansion of macro 'md'
         GetSuff(rc, md, r);
                     ^~
ufo.cpp:5:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define md (l + r >> 1)
             ~~^~~
ufo.cpp:57:24: note: in expansion of macro 'md'
         GetSuff(lc, l, md);
                        ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Incorrect 3 ms 376 KB Output isn't correct
4 Incorrect 17 ms 760 KB Output isn't correct
5 Correct 82 ms 2552 KB Output is correct
6 Incorrect 227 ms 10768 KB Output isn't correct
7 Runtime error 164 ms 44532 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 125 ms 44536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 108 ms 34992 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 126 ms 44572 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 131 ms 47840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 127 ms 44560 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 192 ms 54776 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 136 ms 47836 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 136 ms 44344 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 134 ms 47836 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 234 ms 54648 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 205 ms 57464 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 163 ms 66936 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 482 ms 239632 KB Execution killed with signal 11 (could be triggered by violating memory limits)