답안 #868820

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
868820 2023-11-02T03:30:04 Z Darren0724 Sandcastle 2 (JOI22_ho_t5) C++17
15 / 100
5000 ms 3024 KB
#include<bits/stdc++.h>
using namespace std;
#define LCBorz ios_base::sync_with_stdio(false);cin.tie(0);
#define int long long
#define all(x) x.begin(),x.end()
const int INF=1e18;
const int mod=998244353;
int N;
vector<vector<int>> v;
vector<int> x,y;
int solve(int x1,int y1,int x2,int y2){
    int flag=0;
    int a,b;
    for(int i=1;i<=N;i++){
        if(!(x[i]>=x1&&x[i]<=x2&&y[i]>=y1&&y[i]<=y2)){
            continue;
        }
        if(flag&&abs(a-x[i])+abs(b-y[i])!=1){
            return 0;
        }
        flag=1;
        a=x[i],b=y[i];
    }
    return 1;
}
int32_t main(){
    LCBorz;
    int n,m;cin>>n>>m;
    v.resize(n+2,vector<int>(m+2));
    vector<int> a;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>v[i][j];
            a.push_back(v[i][j]);
        }
    }
    sort(all(a));
    N=n*m;
    x.resize(N+1);
    y.resize(N+1);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            v[i][j]=lower_bound(all(a),v[i][j])-a.begin()+1;
            x[v[i][j]]=i;
            y[v[i][j]]=j;
        }
    }
    int ans=0;
    for(int i1=1;i1<=n;i1++){
        for(int j1=1;j1<=m;j1++){
            for(int i2=i1;i2<=n;i2++){
                for(int j2=j1;j2<=m;j2++){
                    ans+=solve(i1,j1,i2,j2);
                }
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 5031 ms 3024 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1724 ms 572 KB Output is correct
8 Correct 33 ms 344 KB Output is correct
9 Correct 82 ms 500 KB Output is correct
10 Correct 1031 ms 508 KB Output is correct
11 Correct 1431 ms 512 KB Output is correct
12 Correct 1351 ms 536 KB Output is correct
13 Correct 428 ms 500 KB Output is correct
14 Correct 109 ms 592 KB Output is correct
15 Correct 317 ms 348 KB Output is correct
16 Correct 94 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1724 ms 572 KB Output is correct
8 Correct 33 ms 344 KB Output is correct
9 Correct 82 ms 500 KB Output is correct
10 Correct 1031 ms 508 KB Output is correct
11 Correct 1431 ms 512 KB Output is correct
12 Correct 1351 ms 536 KB Output is correct
13 Correct 428 ms 500 KB Output is correct
14 Correct 109 ms 592 KB Output is correct
15 Correct 317 ms 348 KB Output is correct
16 Correct 94 ms 348 KB Output is correct
17 Execution timed out 5034 ms 856 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1724 ms 572 KB Output is correct
8 Correct 33 ms 344 KB Output is correct
9 Correct 82 ms 500 KB Output is correct
10 Correct 1031 ms 508 KB Output is correct
11 Correct 1431 ms 512 KB Output is correct
12 Correct 1351 ms 536 KB Output is correct
13 Correct 428 ms 500 KB Output is correct
14 Correct 109 ms 592 KB Output is correct
15 Correct 317 ms 348 KB Output is correct
16 Correct 94 ms 348 KB Output is correct
17 Execution timed out 5034 ms 856 KB Time limit exceeded
18 Halted 0 ms 0 KB -