Submission #1364428

#TimeUsernameProblemLanguageResultExecution timeMemory
1364428activedeltorreTriple Peaks (IOI25_triples)C++20
Compilation error
0 ms0 KiB
#include "triples.h"
#include <cassert>
#include <cstdio>
#include <vector>

using namespace std;
long long count_triples(std::vector<int> H)
{
    int n=H.size(),hmax=0,z;
    for(int i=1; i<=n; i++)
    {
        hmax=max(hmax,H[i-1]);
    }
    int cnt=0;
    for(int i=1; i<=n; i++)
    {
        j=i-H[i-1];
        if(j>=1)
        {
            z=j+H[j-1];
            if(z+H[z-1]==i)
            {
                cnt++;
            }
        }
    }
    return cnt;
}

Compilation message (stderr)

triples.cpp: In function 'long long int count_triples(std::vector<int>)':
triples.cpp:17:9: error: 'j' was not declared in this scope
   17 |         j=i-H[i-1];
      |         ^