Submission #201490

#TimeUsernameProblemLanguageResultExecution timeMemory
201490EmmanuelACBob (COCI14_bob)C++14
0 / 120
170 ms33656 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long ll dp[1001][1001], ps[1001][1001], ol[1001][1001]; int main(){ cin.tie(0); ios_base::sync_with_stdio(0); int n, m; cin >> n >> m; for(int i=0; i<n; i++){ for(int j=0; j<m; j++){ cin >> ol[i][j]; if(j > 0){ dp[i][j] = 1ll + ((ol[i][j -1] == ol[i][j]) ? dp[i][j -1] : 0ll); } else{ dp[i][j] = 1ll; } } } /* cout << "\n"; for(int i=0; i<n; i++){ for(int j=0; j<m; j++) cout << dp[i][j] << " "; cout << "\n"; } */ ll sol = 0ll; for(int j=0; j<m; j++) ps[0][j] = dp[0][j], sol += dp[0][j]; for(int i=1; i<n; i++){ for(int j=0; j<m; j++){ ps[i][j] = dp[i][j]; if(ol[i][j] == ol[i-1][j]){ ps[i][j] += ps[i-1][j]; if(dp[i -1][j] > dp[i][j]) ps[i][j] -= ps[i -1][j -dp[i][j]]; } sol += ps[i][j]; } } cout << sol << "\n"; }
#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...