제출 #1134690

#제출 시각아이디문제언어결과실행 시간메모리
1134690AlmontherBob (COCI14_bob)C++20
0 / 120
76 ms31816 KiB
#include <bits/stdc++.h> #define ll long long #define co cout<< using namespace std; //stuff void solve(){ ll n,m; cin>>n>>m; ll arr[n+5][m+5]={}; ll left[n+5][m+5]={},right[n+5][m+5]={},up[n+5][m+5]={}; 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]) up[i][j]=up[i-1][j]+1; else up[i][j]=1; if(arr[i][j]==arr[i][j-1]&&up[i][j]<up[i][j-1]) left[i][j]=left[i][j-1]+1; else left[i][j]=1; } for(int j=m;j>=1;j--){ if(arr[i][j]==arr[i][j+1]&&up[i][j]<=up[i][j+1]) right[i][j]=right[i][j+1]+1; else right[i][j]=1; ans+=up[i][j]*left[i][j]*right[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...