1 條題解

  • 0
    @ 2025-12-23 22:22:16
    #include<bits/stdc++.h>
    using namespace std;
    int n,x,y,ans;
    set<pair<int,int> >sp; 
    int main()
    {
    	cin>>n;
    	for(int i=0;i<n;i++)
    	{
    		cin>>x>>y;
    		sp.insert({x,y}); 
    	}
    	for(auto a:sp)
    	{
    		for(auto b:sp)
    		{
    			if(a.first!=b.first&&a.second!=b.second)
    			{
    				if(sp.find({a.first,b.second})!=sp.end()&&sp.find({b.first,a.second})!=sp.end())
    				{
    					ans++;
    				}
    			}
    		}
    	}
    	cout<<ans/4;
    	return 0;
    }
    

    資訊

    ID
    2633
    時間
    1000ms
    記憶體
    256MiB
    難度
    5
    標籤
    遞交數
    5
    已透過
    4
    上傳者