제출 #1134716

#제출 시각아이디문제언어결과실행 시간메모리
1134716AlmontherBob (COCI14_bob)C++20
0 / 120
85 ms31816 KiB
#include <bits/stdc++.h> #define ll long long #define co cout<< using namespace std; //stuff ll n,m; ll arr[1005][1005]={}; ll l[1005][1005]={},r[1005][1005]={},u[1005][1005]={}; void solve(){ cin>>n>>m; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>arr[i][j]; } } ll ans=0; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(arr[i][j]==arr[i-1][j]) u[i][j]=u[i-1][j]+1; else u[i][j]=1; if(arr[i][j]==arr[i][j-1]&&u[i][j]<=u[i][j-1]) l[i][j]=l[i][j-1]+1; else l[i][j]=1; } for(int j=m;j>=1;j--){ if(arr[i][j]==arr[i][j+1]&&u[i][j]<u[i][j+1]) r[i][j]=r[i][j+1]+1; else r[i][j]=1; ans+=u[i][j]*l[i][j]*r[i][j]; } } co ans; } int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int _=1; // cin>>_; while(_--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...