# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
879499 | 2023-11-27T14:48:50 Z | Mr_Husanboy | 별들과 삼각형 (IZhO11_triangle) | C++17 | 337 ms | 24912 KB |
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debugger.cpp" #else #define debug(...) #endif template<class T> int len(T &a){ return a.size(); } using ll = long long; using pii = pair<int,int>; #define all(a) (a).begin(), (a).end() #define ff first #define ss second string fileio = ""; mt19937 mt(time(nullptr)); const int mod = 1e9 + 7; const int inf = 1e9; const ll infl = 1e18; const int maxn = 1e5 + 1; void solve(){ int n; cin >> n; ll ans =0; set<pair<int,int>> st; for(int i = 0; i < n; i ++){ int x, y; cin >> x >> y; st.insert({x, y}); } map<int,vector<int>> mp; map<int,int> cnt; for(auto [x, y] : st){ mp[y].push_back(x); cnt[x] ++; } for(auto [_, vec] : mp){ ll k = len(vec); for(auto u : vec){ ans += (k - 1) * (cnt[u] - 1); } } cout << ans; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); auto start = chrono::high_resolution_clock::now(); #ifndef LOCAL if(fileio.size()){ freopen((fileio + ".in").c_str(), "r", stdin); freopen((fileio + ".out").c_str(), "w", stdout); } #endif int testcases = 1; #ifdef Tests cin >> testcases; #endif while(testcases --){ solve(); cout << '\n'; #ifdef LOCAL cout << "_________________________" << endl; #endif } #ifdef LOCAL auto duration = chrono::duration_cast<chrono::microseconds>(chrono::high_resolution_clock::now() - start); cout << "time: " << (double)duration.count()/1000.0 << " milliseconds" << endl; #endif return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 464 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 464 KB | Output is correct |
7 | Correct | 0 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 360 KB | Output is correct |
11 | Correct | 1 ms | 604 KB | Output is correct |
12 | Correct | 6 ms | 2140 KB | Output is correct |
13 | Correct | 5 ms | 1756 KB | Output is correct |
14 | Correct | 9 ms | 2456 KB | Output is correct |
15 | Correct | 92 ms | 11456 KB | Output is correct |
16 | Correct | 117 ms | 12268 KB | Output is correct |
17 | Correct | 90 ms | 11276 KB | Output is correct |
18 | Correct | 109 ms | 11316 KB | Output is correct |
19 | Correct | 297 ms | 23632 KB | Output is correct |
20 | Correct | 197 ms | 18260 KB | Output is correct |
21 | Correct | 337 ms | 24908 KB | Output is correct |
22 | Correct | 323 ms | 24912 KB | Output is correct |