Submission #1250585

#TimeUsernameProblemLanguageResultExecution timeMemory
1250585s4dzTriple Peaks (IOI25_triples)C++20
Compilation error
0 ms0 KiB
long long count_triples(vector<signed> H)
{
    int n = H.size();
    long long ans = 0;
    //Hk = k - i, Hi = j - i, Hj = k - j
    for(int j = 0; j < n; j++)
    {
        for(int i = max(0LL, j - H[j] + 1); i < j && i + H[j] < n; i++)
        {
            int k = i + H[j];
            int x = H[k], y = H[i];
            int d1 = j - i, d2 = k - j;
            if((H[k] == d1 && H[i] == d2) || (H[k] == d2 && H[i] == d1)) ans++;
        }
        int l = j - H[j];
        if(l >= 0)
        {
            int x = H[l];
            int y = H[j] - x;
            if(y > 0)
            {
                if(H[l + x] == y) ans++;
                if(y != x && H[l + y] == y) ans++;
            }
        }
        int r = j + H[j];
        if(r < n)
        {
            int x = H[r];
            int y = H[j] - x;
            if(y > 0)
            {
                if(H[j + x] == y) ans++;
                if(y != x && H[j + y] == y) ans++;
            }
        }
    }
}

Compilation message (stderr)

triples.cpp:1:25: error: 'vector' was not declared in this scope
    1 | long long count_triples(vector<signed> H)
      |                         ^~~~~~
triples.cpp:1:32: error: expected primary-expression before 'signed'
    1 | long long count_triples(vector<signed> H)
      |                                ^~~~~~