# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
594190 | 2022-07-12T08:04:27 Z | 조영욱(#8434) | Sandcastle 2 (JOI22_ho_t5) | C++17 | 5000 ms | 724 KB |
#include <bits/stdc++.h> using namespace std; int n,m; int arr[100][50000]; typedef pair<int,int> P; typedef pair<int,P> iP; int main() { scanf("%d %d",&n,&m); for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { scanf("%d",&arr[i][j]); } } if (n==1) { long long ret=-m; int pr=0; for(int i=1;i<m;i++) { if (arr[0][i-1]>arr[0][i]) { ret+=1LL*(i-pr)*(i+1-pr)/2; pr=i; } } ret+=1LL*(m-pr)*(m+1-pr)/2; pr=0; for(int i=1;i<m;i++) { if (arr[0][i-1]<arr[0][i]) { ret+=1LL*(i-pr)*(i+1-pr)/2; pr=i; } } ret+=1LL*(m-pr)*(m+1-pr)/2; printf("%lld",ret); return 0; } int ret=0; for(int x1=0;x1<n;x1++) { for(int y1=0;y1<m;y1++) { for(int x2=x1;x2<n;x2++) { for(int y2=y1;y2<m;y2++) { vector<iP> v; for(int i=x1;i<=x2;i++) { for(int j=y1;j<=y2;j++) { v.push_back(iP(arr[i][j],P(i,j))); } } sort(v.begin(),v.end()); bool flag=true; for(int i=0;i+1<v.size();i++) { if (abs(v[i+1].second.first-v[i].second.first)+abs(v[i+1].second.second-v[i].second.second)!=1) { flag=false; break; } } if (flag) { ret++; } } } } } printf("%d",ret); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 5 ms | 444 KB | Output is correct |
3 | Correct | 5 ms | 468 KB | Output is correct |
4 | Correct | 5 ms | 468 KB | Output is correct |
5 | Correct | 7 ms | 468 KB | Output is correct |
6 | Correct | 5 ms | 468 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 340 KB | Output is correct |
2 | Correct | 2 ms | 340 KB | Output is correct |
3 | Correct | 2 ms | 340 KB | Output is correct |
4 | Correct | 2 ms | 340 KB | Output is correct |
5 | Correct | 2 ms | 340 KB | Output is correct |
6 | Correct | 2 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 340 KB | Output is correct |
2 | Correct | 2 ms | 340 KB | Output is correct |
3 | Correct | 2 ms | 340 KB | Output is correct |
4 | Correct | 2 ms | 340 KB | Output is correct |
5 | Correct | 2 ms | 340 KB | Output is correct |
6 | Correct | 2 ms | 340 KB | Output is correct |
7 | Execution timed out | 5055 ms | 724 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 340 KB | Output is correct |
2 | Correct | 2 ms | 340 KB | Output is correct |
3 | Correct | 2 ms | 340 KB | Output is correct |
4 | Correct | 2 ms | 340 KB | Output is correct |
5 | Correct | 2 ms | 340 KB | Output is correct |
6 | Correct | 2 ms | 340 KB | Output is correct |
7 | Execution timed out | 5055 ms | 724 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 340 KB | Output is correct |
2 | Correct | 2 ms | 340 KB | Output is correct |
3 | Correct | 2 ms | 340 KB | Output is correct |
4 | Correct | 2 ms | 340 KB | Output is correct |
5 | Correct | 2 ms | 340 KB | Output is correct |
6 | Correct | 2 ms | 340 KB | Output is correct |
7 | Execution timed out | 5055 ms | 724 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |