# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
921661 | 2024-02-04T08:52:49 Z | airmoon | Star triangles (IZhO11_triangle) | C++17 | 1 ms | 600 KB |
#include <vector> #include <algorithm> #include <cstdio> #include <string> #include <utility> #include <set> #include <numeric> #include <cmath> #include <queue> #include <stack> #include <climits> #include <map> #include <iostream> using namespace std; using ll = long long; using vi = vector<int>; using vb = vector<bool>; using vll = vector<ll>; #define ff first #define ss second //#define int long long int void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } ll nCr(int n, int r){ if(n<r) return 0; if(n==r) return 1; ll eto=1; for(int i=(n-2+1); i<=n; ++i){ eto*=i; } return eto/4; } void solve(){ int n; cin >> n; vector<pair<int,int>>a(n); map<int,int>cnt; int sum=0; for(int i=0; i<n; ++i){ cin >> a[i].ff >> a[i].ss; cnt[a[i].ss]++; } for(auto &i : cnt){ sum+=i.ss; } ll ans=0; for(int i=0; i<n; ++i){ ans+=(nCr(sum-cnt[a[i].ss], 2)); } cout << ans << "\n"; } int main(){ //signed main(){ //setIO("triangle"); int T=1; //cin >> T; for(int i=0; i<T; ++i) solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 600 KB | Output is correct |
4 | Incorrect | 0 ms | 348 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |