제출 #879499

#제출 시각아이디문제언어결과실행 시간메모리
879499Mr_Husanboy별들과 삼각형 (IZhO11_triangle)C++17
100 / 100
337 ms24912 KiB
#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; }

컴파일 시 표준 에러 (stderr) 메시지

triangle.cpp: In function 'int main()':
triangle.cpp:60:10: warning: variable 'start' set but not used [-Wunused-but-set-variable]
   60 |     auto start = chrono::high_resolution_clock::now();
      |          ^~~~~
triangle.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen((fileio + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
triangle.cpp:64:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         freopen((fileio + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...