Submission #1095220

#TimeUsernameProblemLanguageResultExecution timeMemory
1095220SoMotThanhXuanBob (COCI14_bob)C++17
24 / 120
74 ms14108 KiB
#include <bits/stdc++.h> using namespace std; const int maxN = 1e3 + 5; int a[maxN][maxN], N, M; namespace subtask1{ bool check(){ return max(N, M) <= 50; } bool ok[51][51][51][51]; void solve(){ int res = 0; for(int i = 1; i <= N; ++i)for(int j = 1; j <= M; ++j)ok[i][j][i][j] = 1; for(int i = 1; i <= N; ++i){ for(int j = 1; j <= M; ++j){ for(int x = i + 1; x <= N; ++x){ if(a[i][j] == a[x][j]) ok[i][j][x][j] = ok[i][j][x - 1][j]; } for(int y = j + 1; y <= M; ++y){ if(a[i][j] == a[i][y]) ok[i][j][i][y] = ok[i][j][i][y - 1]; } for(int x = i + 1; x <= N; ++x){ for(int y = j + 1; y <= M; ++y){ if(a[x][y] == a[i][j]){ ok[i][j][x][y] = ok[i][j][x - 1][y] && ok[i][j][x][y - 1]; } } } } } for(int i = 1; i <= N; ++i)for(int j = 1; j <= M; ++j)for(int x = i; x <= N; ++x)for(int y = j; y <= M; ++y) if(ok[i][j][x][y]){ ++res; } cout << res; } } int main(){ // freopen("s2.inp", "r", stdin); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> N >> M; for(int i = 1; i <= N; ++i) for(int j = 1; j <= M; ++j){ cin >> a[i][j]; } if(subtask1 :: check()) return subtask1 :: solve(), 0; 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...