# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
21883 | 2017-04-26T16:01:47 Z | ulna | Star triangles (IZhO11_triangle) | C++11 | 0 ms | 4376 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4376 KB | Output is correct |
2 | Correct | 0 ms | 4376 KB | Output is correct |
3 | Correct | 0 ms | 4376 KB | Output is correct |
4 | Correct | 0 ms | 4376 KB | Output is correct |
5 | Correct | 0 ms | 4376 KB | Output is correct |
6 | Incorrect | 0 ms | 4376 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |