제출 #1364300

#제출 시각아이디문제언어결과실행 시간메모리
1364300mannshah12113개의 봉우리 (IOI25_triples)C++20
컴파일 에러
0 ms0 KiB
#include "triples.h"

using namespace std;

long long count_triples(vector<int> h) {
  int n = h.size();
  auto In = [&](int i) {
    return (0 <= i) && (i < n);
  };
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int k = h[i] + i;
    if (In(k)) {
      int case1j = h[k] + i, case2j = k - h[k];
      if (In(case1j) && h[case1j] == k - case1j) {
        ans++;
      }
      if (In(case2j) && h[case2j] == case2j - i && case1j != case2j) {
        ans++;
      }
    }
  }
  for (int k = n - 1; k >= 0; k--) {
    int i = k - h[k];
    if (In(i)) {
      int case1j = h[i] + i, case2j = k - h[i];
      if (In(case1j) && h[case1j] == k - case1j) {
        ans++;
      }
      if (In(case2j) && h[case2j] == case2j - i && case1j != case2j) {
        ans++;
      }
    }
  }
  map<int, int> mp;
  for (int j = 0; j < n; j++) {
    if (mp[h[j]] != 0) {
      int i = mp[h[j]] - 1, k = h[j] + i;
      if (In(k) && k - h[k] == j) {
        ans++;
      }
    }
    mp[h[j] + j] = j + 1;
  }
  return ans;
}

vector<int> construct_range(int m, int k) {
  
}

컴파일 시 표준 에러 (stderr) 메시지

triples.cpp: In function 'long long int count_triples(std::vector<int>)':
triples.cpp:35:3: error: 'map' was not declared in this scope
   35 |   map<int, int> mp;
      |   ^~~
triples.cpp:2:1: note: 'std::map' is defined in header '<map>'; did you forget to '#include <map>'?
    1 | #include "triples.h"
  +++ |+#include <map>
    2 | 
triples.cpp:35:7: error: expected primary-expression before 'int'
   35 |   map<int, int> mp;
      |       ^~~
triples.cpp:37:9: error: 'mp' was not declared in this scope
   37 |     if (mp[h[j]] != 0) {
      |         ^~
triples.cpp:39:14: error: 'k' was not declared in this scope
   39 |       if (In(k) && k - h[k] == j) {
      |              ^
triples.cpp:43:5: error: 'mp' was not declared in this scope
   43 |     mp[h[j] + j] = j + 1;
      |     ^~
triples.cpp: In function 'std::vector<int> construct_range(int, int)':
triples.cpp:50:1: warning: no return statement in function returning non-void [-Wreturn-type]
   50 | }
      | ^