Submission #21883

#TimeUsernameProblemLanguageResultExecution timeMemory
21883ulnaStar triangles (IZhO11_triangle)C++11
0 / 100
0 ms4376 KiB
#include <bits/stdc++.h> using namespace std; // why am I so weak int n; int x[300055], y[300055]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d %d", &x[i], &y[i]); } long long res = 0ll; vector<int> vec(n); for (int i = 0; i < n; i++) { vec[i] = i; } { // find bottom left sort(vec.begin(), vec.end(), [&] (int u, int v) { if (y[u] != y[v]) return y[u] > y[v]; return x[u] > x[v]; }); map<int, int> c; int ac = 0; int last = -INT_MAX; for (auto u : vec) { if (y[u] != last) { ac = 0; } res += 1ll * ac * c[x[u]]; c[x[u]]++; ac++; last = y[u]; } } { // find bottom right sort(vec.begin(), vec.end(), [&] (int u, int v) { if (y[u] != y[v]) return y[u] > y[v]; return x[u] < x[v]; }); map<int, int> c; int ac = 0; int last = -INT_MAX; for (auto u : vec) { if (y[u] != last) { ac = 0; } res += 1ll * ac * c[x[u]]; c[x[u]]++; ac++; last = y[u]; } } { // find top left sort(vec.begin(), vec.end(), [&] (int u, int v) { if (y[u] != y[v]) return y[u] < y[v]; return x[u] < x[v]; }); map<int, int> c; int ac = 0; int last = -INT_MAX; for (auto u : vec) { if (y[u] != last) { ac = 0; } res += 1ll * ac * c[x[u]]; c[x[u]]++; ac++; last = y[u]; } } { // find top right sort(vec.begin(), vec.end(), [&] (int u, int v) { if (y[u] != y[v]) return y[u] < y[v]; return x[u] < x[v]; }); map<int, int> c; int ac = 0; int last = -INT_MAX; for (auto u : vec) { if (y[u] != last) { ac = 0; } res += 1ll * ac * c[x[u]]; c[x[u]]++; ac++; last = y[u]; } } printf("%lld\n", res); return 0; }

Compilation message (stderr)

triangle.cpp: In function 'int main()':
triangle.cpp:10:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
triangle.cpp:13:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &x[i], &y[i]);
                               ^
#Verdict Execution timeMemoryGrader output
Fetching results...