Submission #23008

# Submission time Handle Problem Language Result Execution time Memory
23008 2017-05-01T11:35:23 Z cprayer Unifying Values (KRIII5_UV) C++14
Compilation error
0 ms 0 KB
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

const int MAXN = 1e4 + 9, MOD = 1e9 + 7;
long long A[MAXN];
int N;
pair<int, bool> dp[MAXN];
set<long long> chk;

int f(int i, int p, long long current, long long v){
    auto &res = dp[p];
    int c = 0;
    cnt++;
    if(i == N - 1) return ((current == v) && p) ? 1 : 0;
    if(res.second) return res.first;
    c += f(i + 1, p, current + A[i + 1], v);
    c %= MOD;
    if(current == v){
        c += f(i + 1, i + 1, A[i + 1], v);
        c %= MOD;
    }
    if(i == p) res.second = true;
    return res.first = c;
}

int main(){
    scanf("%d", &N);
    for(int i = 0; i < N; i++) scanf("%lld", &A[i]);
    long long ans = 0, s = 0;
    for(int i = 0; i < N; i++){
        s += A[i];
        if(chk.find(s) == chk.end()){
            ans += f(i, 0, s, s);
            chk.insert(s);
            for(int j = 0; j < N; j++) dp[j] = make_pair(0, 0);
        }
        ans %= MOD;
    }
    printf("%lld", ans);
}

Compilation message

UV.cpp: In function 'int f(int, int, long long int, long long int)':
UV.cpp:17:5: error: 'cnt' was not declared in this scope
     cnt++;
     ^
UV.cpp: In function 'int main()':
UV.cpp:31:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
                    ^
UV.cpp:32:52: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 0; i < N; i++) scanf("%lld", &A[i]);
                                                    ^