답안 #534263

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
534263 2022-03-08T02:49:29 Z balbit Sandcastle 2 (JOI22_ho_t5) C++14
10 / 100
5000 ms 4160 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define pii pair<int, int>
#define f first
#define s second

#define REP(i,n) for (int i = 0; i<n; ++i)
#define REP1(i,n) for (int i = 1; i<=n; ++i)

#define SZ(x) (int)((x).size())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back

#define MX(a,b) a = max(a,b)
#define MN(a,b) a = min(a,b)

#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<" "<<#__VA_ARGS__<<" - ", _do(__VA_ARGS__)
template <typename T> void _do( T && x) {cerr<<x<<endl;}
template <typename T, typename ...S> void _do( T && x, S && ...y) {cerr<<x<<", "; _do(y...);}
#else
#define bug(...)
#define endl '\n'
#endif // BALBIT

//const int maxn = 7000*7000+5;

vector<vector<int> > G;
vector<int> legal[50005];

void upd(int a, int b) {
    if (a < b) {
        legal[a].pb(b);
    }
}

bool ok(int a, int b) {
    return find(ALL(legal[a]), b) != legal[a].end();
}

signed main(){
    ios::sync_with_stdio(0), cin.tie(0);

    bug(1,2);

    int n,m; cin>>n>>m;
    G.resize(n, vector<int> (m));
    vector<int> ol;
    REP(i,n) REP(j,m) {
        cin>>G[i][j];
        ol.pb(G[i][j]);
    }
    sort(ALL(ol));
    REP(i,n) REP(j,m) {
        G[i][j] = lower_bound(ALL(ol), G[i][j]) - ol.begin();
    }
    REP(i,n) REP(j,m) {
        if (i) upd(G[i][j], G[i-1][j]);
        if (i<n-1) upd(G[i][j], G[i+1][j]);
        if (j<m-1) upd(G[i][j], G[i][j+1]);
        if (j) upd(G[i][j], G[i][j-1]);
    }

    int re =0 ;

    REP(h2, n) {
        REP(h1, h2+1) {
            // using only rows from h1 to h2
            // play ball
            for( int w1 = 0; w1 < m; ++w1) {
                // for subtask... just enumerate w1, w2...
                vector<int> tmp;
                for( int w2 = w1; w2 < m; ++w2) {
                    for (int k = h1; k<=h2; ++k) {
                        tmp.pb(G[k][w2]);
                    }
                    sort(ALL(tmp));
                    REP(i, SZ(tmp)-1) {
                        if (!ok(tmp[i], tmp[i+1])) {
                            goto nope;
                        }
                    }
                    re++;
                    nope:;
                }
            }
        }
    }
    cout<<re<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1356 KB Output is correct
2 Execution timed out 5047 ms 4160 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1484 KB Output is correct
2 Correct 2 ms 1484 KB Output is correct
3 Correct 2 ms 1488 KB Output is correct
4 Correct 2 ms 1484 KB Output is correct
5 Correct 2 ms 1484 KB Output is correct
6 Correct 3 ms 1484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1484 KB Output is correct
2 Correct 2 ms 1484 KB Output is correct
3 Correct 2 ms 1488 KB Output is correct
4 Correct 2 ms 1484 KB Output is correct
5 Correct 2 ms 1484 KB Output is correct
6 Correct 3 ms 1484 KB Output is correct
7 Execution timed out 5007 ms 1648 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1484 KB Output is correct
2 Correct 2 ms 1484 KB Output is correct
3 Correct 2 ms 1488 KB Output is correct
4 Correct 2 ms 1484 KB Output is correct
5 Correct 2 ms 1484 KB Output is correct
6 Correct 3 ms 1484 KB Output is correct
7 Execution timed out 5007 ms 1648 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1484 KB Output is correct
2 Correct 2 ms 1484 KB Output is correct
3 Correct 2 ms 1488 KB Output is correct
4 Correct 2 ms 1484 KB Output is correct
5 Correct 2 ms 1484 KB Output is correct
6 Correct 3 ms 1484 KB Output is correct
7 Execution timed out 5007 ms 1648 KB Time limit exceeded
8 Halted 0 ms 0 KB -