답안 #574051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
574051 2022-06-07T16:08:38 Z MohammadAghil 별들과 삼각형 (IZhO11_triangle) C++14
100 / 100
348 ms 13388 KB
      #include <bits/stdc++.h>
//   #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("avx2")
    using namespace std;
  typedef long long ll;
   typedef pair<int, int> pp;
    #define er(args ...) cerr << __LINE__ << ": ", err(new istringstream(string(#args)), args), cerr << endl
      #define per(i,r,l) for(int i = (r); i >= (l); i--)
        #define rep(i,l,r) for(int i = (l); i < (r); i++)
           #define all(x) x.begin(), x.end()
              #define sz(x) (int)(x).size()
                  #define pb push_back
                      #define ss second
                           #define ff first
                                   void err(istringstream *iss){}template<typename T,typename ...Args> void err(istringstream *iss,const T &_val, const Args&...args){string _name;*iss>>_name;if(_name.back()==',')_name.pop_back();cerr<<_name<<" = "<<_val<<", ",err(iss,args...);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod = 1e9 + 7, maxn = 1e5 + 5, lg = 21, inf = ll(1e9) + 5;
ll pw(ll a,ll b,ll md=mod){if(!b)return 1;ll k=pw(a,b>>1ll);return k*k%md*(b&1ll?a:1)%md;}

int main(){
     cin.tie(0) -> sync_with_stdio(0);
     int n; cin >> n;
     map<int, int> x, y;
     vector<pp> p;
     rep(i,0,n){
          int a, b; cin >> a >> b; 
          x[b]++, y[a]++, p.pb({a, b});
     }
     ll ans = 0;
     for(auto[a, b]: p) ans += 1ll*(x[b]-1)*(y[a]-1);
     cout << ans << '\n';
     return 0; 
}

Compilation message

triangle.cpp: In function 'int main()':
triangle.cpp:30:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   30 |      for(auto[a, b]: p) ans += 1ll*(x[b]-1)*(y[a]-1);
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 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 2 ms 336 KB Output is correct
12 Correct 6 ms 980 KB Output is correct
13 Correct 6 ms 1108 KB Output is correct
14 Correct 9 ms 1364 KB Output is correct
15 Correct 92 ms 6176 KB Output is correct
16 Correct 102 ms 6388 KB Output is correct
17 Correct 123 ms 6172 KB Output is correct
18 Correct 111 ms 6100 KB Output is correct
19 Correct 252 ms 13312 KB Output is correct
20 Correct 191 ms 9204 KB Output is correct
21 Correct 348 ms 13388 KB Output is correct
22 Correct 283 ms 13264 KB Output is correct