Submission #1251382

#TimeUsernameProblemLanguageResultExecution timeMemory
1251382tranvinhhuy20103개의 봉우리 (IOI25_triples)C++20
Compilation error
0 ms0 KiB
#include "triples.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int nmax = 2e5 + 5;
int n;
unordered_map <int, set <int>> mk;

ll count_triples(vector <int> H) {
    n = H.size();
    ll cnt = 0;
    for (int j=0; j<n; j++) {
        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) cnt++;
                if(y != x && H[l + y] == y) cnt++;
            }
        }
        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) cnt++;
                if(y != x && H[j + y] == y) cnt++;
            }
        }

        mk[j - H[j]].insert(i);
    }

    for (int i=0; i<n; i++) {
        mk[i - H[i]].erase(i);

        for (int k : mk[i + H[i]]) {
            int j = i + H[k];
            if (j<k && H[j]==k-i) cnt++;
        }
    }

    return cnt;
}

vector<int> construct_range(int M, int K) {
    return {1, 1, 1};
}

Compilation message (stderr)

triples.cpp: In function 'll count_triples(std::vector<int>)':
triples.cpp:39:29: error: 'i' was not declared in this scope
   39 |         mk[j - H[j]].insert(i);
      |                             ^