답안 #1100544

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1100544 2024-10-14T08:36:01 Z vjudge1 별들과 삼각형 (IZhO11_triangle) C++17
0 / 100
2 ms 336 KB
// Bolatulu
#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define kanagattandirilmagandiktarinizdan ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ins insert
#define F first
#define S second
#define fx cout << fixed << setprecision(4);
#define md (tl+tr)/2
#define TL v+v, tl,md
#define TR v+v+1, md+1,tr
#define Tl t[v].l, tl,md
#define Tr t[v].r, md+1,tr
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define all(x) (x).begin(), (x).end()
#define int ll
#define cnk(n,k) mod(mod(f[(n)]*binpow(f[(n)-(k)],M-2))*binpow(f[(k)],M-2))
#define cnkf(n,k) mod(mod(f[(n)]*inv[(n)-(k)])*inv[(k)])

using namespace std;

typedef complex<double> cd;

struct mine{int l;int r;int i;};
struct edge{int u;int v;int w;};
struct tree{int l;int r;int val;};

auto cmp = [](mine a, mine b) { return a.i<b.i; };

mt19937 RR((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
 
int random(int l, int r){
  return uniform_int_distribution<int>(l, r)(RR);
}

int M=998244353;

int mod1(int a,int b=M) {
    if (a<0)
        a=b+a%b;
    return a % b;
}

int binpow(int a,int n,int m=M) {
    a=mod1(a,m);
    if (!n)
        return 1;
    if (n&1)
        return (a * binpow(a,n-1))%m;
    int x = binpow(a,n>>1);
    return (x*x)%m; 
}

const ll INF=1e18+7;
const int N=3e5+7;

int n;
int x[N],y[N];
set <int> sx,sy;
map <int,vector <int>> mpx;
map <int,int> cy,cx;
set <pair <int,int>> s;

void solve() {
    cin >> n;
    for (int i=1;i<=n;i++) {
        cin >> x[i] >> y[i];
        if (s.find({x[i],y[i]})==s.end()) {
            s.insert({x[i],y[i]});
            sx.insert(x[i]);
            sy.insert(y[i]);
            mpx[x[i]].pb(y[i]);
            cy[y[i]]++;
            cx[x[i]]++;
        }
    }
    int ans=0;
    for (auto now : sx) {
        sort(all(mpx[now]));
        for (int i=0;i<mpx[now].size();i++) {
            int cur=mpx[now][i];
            ans+=(cx[now]-1)*(cy[cur]-1);
        }
    }
    cout << ans;
}   

signed main() {
    freopen("triangles.in", "r", stdin);
    freopen("triangles.out", "w", stdout);
    // fx
    kanagattandirilmagandiktarinizdan
    int test = 1, count = 1;
    // cin >> test;
    while (test--) {
        // cout << "Case " << count << ":\n";
        solve();
        if (test) {
            cout << '\n';
            count++;
        }
    }
    return 0;
}

// ctrl + shift + p make stress isis__Good isis__Generator
// g++ -std=c++17 (path) -o run
// .\run

Compilation message

triangle.cpp: In function 'void solve()':
triangle.cpp:87:23: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |         for (int i=0;i<mpx[now].size();i++) {
      |                      ~^~~~~~~~~~~~~~~~
triangle.cpp: In function 'int main()':
triangle.cpp:96:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   96 |     freopen("triangles.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
triangle.cpp:97:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   97 |     freopen("triangles.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -