Submission #1095220

# Submission time Handle Problem Language Result Execution time Memory
1095220 2024-10-01T15:17:00 Z SoMotThanhXuan Bob (COCI14_bob) C++17
24 / 120
74 ms 14108 KB
#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 time Memory Grader output
1 Correct 9 ms 7004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 2908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 3176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 3416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 3460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 10952 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 74 ms 14108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 13768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 13908 KB Output isn't correct
2 Halted 0 ms 0 KB -