제출 #1364429

#제출 시각아이디문제언어결과실행 시간메모리
1364429activedeltorreTriple Peaks (IOI25_triples)C++20
컴파일 에러
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;
}

std::vector<int> construct_range(int M, int K)
{
    vector<int>rasp;
    for(int i=0; i<M; i++)
    {
        if(i%3==1)
            rasp.push_back(2);
        else
            rasp.push_back(1);
    }
    return rasp;
}

컴파일 시 표준 에러 (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];
      |         ^