Submission #573242

#TimeUsernameProblemLanguageResultExecution timeMemory
573242guugiuhLightning Rod (NOI18_lightningrod)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <iostream> #include <cstdio> #include <cstdlib> #include <vector> using namespace std; inline int readInt() { int x = 0; char ch = getchar_unlocked(); while (ch < '0' || ch > '9') ch = getchar_unlocked(); while (ch >= '0' && ch <= '9'){ x = (x << 3) + (x << 1) + ch - '0'; ch = getchar_unlocked(); } return x; } int MinPyramids(int N, vi X, vi Y) { int res = 0; vi T1(N + 1), T2(N + 1); for (int i = 0; i < N; i++) T1[N - i] = X[i] - Y[i], T2[i + 1] = X[i] + Y[i]; for (int i = 0; i < N; i++) if (i + (i & -i) <= N) T1[i + (i & -i)] = min(T1[i + (i & -i)], T1[i]), T2[i + (i & -i)] = max(T2[i + (i & -i)], T2[i]); for (int i = 0; i < N; i++) { int mn = 2e9+1, mx = -mn; for (int j = N - i - 1; j > 0; j -= j & -j) mn = min(mn, T1[j]); for (int j = i; j > 0; j -= j & -j) mx = max(mx, T2[j]); if (mx < X[i] + Y[i] && mn > X[i] - Y[i]) res++; } return res; } int main(){ int N = readInt(); vector <int> X(N); vector <int> Y(N); for(int i = 0; i < N; i++) { X[i] = readInt(); Y[i] = readInt(); } int ans= MinPyramids(N,X,Y); printf("%d", ans); return 0; }

Compilation message (stderr)

lightningrod.cpp:18:24: error: 'vi' has not been declared
   18 | int MinPyramids(int N, vi X, vi Y)
      |                        ^~
lightningrod.cpp:18:30: error: 'vi' has not been declared
   18 | int MinPyramids(int N, vi X, vi Y)
      |                              ^~
lightningrod.cpp: In function 'int MinPyramids(int, int, int)':
lightningrod.cpp:21:5: error: 'vi' was not declared in this scope
   21 |     vi T1(N + 1), T2(N + 1);
      |     ^~
lightningrod.cpp:23:9: error: 'T1' was not declared in this scope; did you mean 'y1'?
   23 |         T1[N - i] = X[i] - Y[i], T2[i + 1] = X[i] + Y[i];
      |         ^~
      |         y1
lightningrod.cpp:23:22: error: invalid types 'int[int]' for array subscript
   23 |         T1[N - i] = X[i] - Y[i], T2[i + 1] = X[i] + Y[i];
      |                      ^
lightningrod.cpp:23:29: error: invalid types 'int[int]' for array subscript
   23 |         T1[N - i] = X[i] - Y[i], T2[i + 1] = X[i] + Y[i];
      |                             ^
lightningrod.cpp:23:34: error: 'T2' was not declared in this scope
   23 |         T1[N - i] = X[i] - Y[i], T2[i + 1] = X[i] + Y[i];
      |                                  ^~
lightningrod.cpp:23:47: error: invalid types 'int[int]' for array subscript
   23 |         T1[N - i] = X[i] - Y[i], T2[i + 1] = X[i] + Y[i];
      |                                               ^
lightningrod.cpp:23:54: error: invalid types 'int[int]' for array subscript
   23 |         T1[N - i] = X[i] - Y[i], T2[i + 1] = X[i] + Y[i];
      |                                                      ^
lightningrod.cpp:26:13: error: 'T1' was not declared in this scope; did you mean 'y1'?
   26 |             T1[i + (i & -i)] = min(T1[i + (i & -i)], T1[i]), T2[i + (i & -i)] = max(T2[i + (i & -i)], T2[i]);
      |             ^~
      |             y1
lightningrod.cpp:26:62: error: 'T2' was not declared in this scope
   26 |             T1[i + (i & -i)] = min(T1[i + (i & -i)], T1[i]), T2[i + (i & -i)] = max(T2[i + (i & -i)], T2[i]);
      |                                                              ^~
lightningrod.cpp:31:26: error: 'T1' was not declared in this scope; did you mean 'y1'?
   31 |             mn = min(mn, T1[j]);
      |                          ^~
      |                          y1
lightningrod.cpp:33:26: error: 'T2' was not declared in this scope
   33 |             mx = max(mx, T2[j]);
      |                          ^~
lightningrod.cpp:34:19: error: invalid types 'int[int]' for array subscript
   34 |         if (mx < X[i] + Y[i] && mn > X[i] - Y[i])
      |                   ^
lightningrod.cpp:34:26: error: invalid types 'int[int]' for array subscript
   34 |         if (mx < X[i] + Y[i] && mn > X[i] - Y[i])
      |                          ^
lightningrod.cpp:34:39: error: invalid types 'int[int]' for array subscript
   34 |         if (mx < X[i] + Y[i] && mn > X[i] - Y[i])
      |                                       ^
lightningrod.cpp:34:46: error: invalid types 'int[int]' for array subscript
   34 |         if (mx < X[i] + Y[i] && mn > X[i] - Y[i])
      |                                              ^
lightningrod.cpp: In function 'int main()':
lightningrod.cpp:48:25: error: cannot convert 'std::vector<int>' to 'int'
   48 |  int ans= MinPyramids(N,X,Y);
      |                         ^
      |                         |
      |                         std::vector<int>
lightningrod.cpp:18:27: note:   initializing argument 2 of 'int MinPyramids(int, int, int)'
   18 | int MinPyramids(int N, vi X, vi Y)
      |                        ~~~^