답안 #561661

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
561661 2022-05-13T10:34:04 Z KiriLL1ca 별들과 삼각형 (IZhO11_triangle) C++14
100 / 100
300 ms 13280 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fr first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pw(x) (1ll << x)
#define sz(x) (int)((x).size())
#define pb push_back
#define endl '\n'
#define vec vector

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

template <typename T> inline bool umin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool umax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }

template <typename T>
using oset = tree<T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

inline void solve () {
      int n; cin >> n;
      vector <pii> a (n);
      map <int, ll> cntX, cntY;
      for (auto &[x, y] : a) cin >> x >> y, ++cntX[x], ++cntY[y];
      ll ans = 0;
      for (auto &[x, y] : a) ans += (cntX[x] - 1) * (cntY[y] - 1);
      cout << ans << endl;
}

signed main() {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      int t = 1; //cin >> t;
      while (t--) solve();
      return 0;
}

Compilation message

triangle.cpp: In function 'void solve()':
triangle.cpp:31:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   31 |       for (auto &[x, y] : a) cin >> x >> y, ++cntX[x], ++cntY[y];
      |                  ^
triangle.cpp:33:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   33 |       for (auto &[x, y] : a) ans += (cntX[x] - 1) * (cntY[y] - 1);
      |                  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 6 ms 1108 KB Output is correct
13 Correct 6 ms 1108 KB Output is correct
14 Correct 10 ms 1672 KB Output is correct
15 Correct 101 ms 7076 KB Output is correct
16 Correct 108 ms 7356 KB Output is correct
17 Correct 99 ms 7116 KB Output is correct
18 Correct 101 ms 7072 KB Output is correct
19 Correct 269 ms 12516 KB Output is correct
20 Correct 205 ms 10252 KB Output is correct
21 Correct 295 ms 13156 KB Output is correct
22 Correct 300 ms 13280 KB Output is correct