Submission #543201

# Submission time Handle Problem Language Result Execution time Memory
543201 2022-03-29T19:02:13 Z ahmet34 Bob (COCI14_bob) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
#define all(x) x.begin(), x.end()

const int INF = 2e9, N = 55, M = 998244353, LOG = 16;
const ll LINF = 1e18;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m; 
    cin >> n >> m;

    vector v(n, vector<int>(m));

    for(auto& vi : v) for(int& x: vi) cin >> x;

    vector dp(n, vector<ll>(m));
        
    auto isValid = [&] (int x, int y) {
        return x >= 0  && y >= 0 && x < n && y < m;
    };

    ll ans = 0;

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            dp[i][j] = 1;
            
            bool adj = false;

            if(isValid(i-1, j) and v[i-1][j] == v[i][j]) {
                dp[i][j] += dp[i-1][j];
                adj = true;
            }

            if(isValid(i, j-1) and v[i][j] == v[i][j-1]) {
                dp[i][j] += dp[i][j-1];
                adj = true;
            }

            if(isValid(i-1, j-1) and adj and v[i-1][j-1] == v[i][j])
                dp[i][j] -= dp[i-1][j-1];

            ans += dp[i][j];
            //cout << dp[i][j] << ' ';
        }
        //cout << endl;
    }
    cout << ans;
}

Compilation message

bob.cpp: In function 'int main()':
bob.cpp:16:12: error: missing template arguments before 'v'
   16 |     vector v(n, vector<int>(m));
      |            ^
bob.cpp:18:20: error: 'v' was not declared in this scope; did you mean 'vi'?
   18 |     for(auto& vi : v) for(int& x: vi) cin >> x;
      |                    ^
      |                    vi
bob.cpp:20:12: error: missing template arguments before 'dp'
   20 |     vector dp(n, vector<ll>(m));
      |            ^~
bob.cpp:30:13: error: 'dp' was not declared in this scope
   30 |             dp[i][j] = 1;
      |             ^~
bob.cpp:34:36: error: 'v' was not declared in this scope
   34 |             if(isValid(i-1, j) and v[i-1][j] == v[i][j]) {
      |                                    ^
bob.cpp:39:36: error: 'v' was not declared in this scope
   39 |             if(isValid(i, j-1) and v[i][j] == v[i][j-1]) {
      |                                    ^
bob.cpp:44:46: error: 'v' was not declared in this scope
   44 |             if(isValid(i-1, j-1) and adj and v[i-1][j-1] == v[i][j])
      |                                              ^