3 条题解

  • 0
    @ 2024-10-2 18:16:07
    #include<bits/stdc++.h>
    const int N=1e6+5;
    int a[N],b[N],c[N];
    long long ans=0;
    using namespace std;
    map<int, int> mp;
    int main()
    {
    	int n;
    	cin>>n;
    	for(int i=1;i<=n;i++)
    	{
    		cin>>a[i];
    	}
    	for(int i=1;i<=n;i++)
    	{
    		cin>>b[i];
    	}
    	for(int i=1;i<=n;i++)
    	{
    		cin>>c[i];
    	}
    	for (int i = 1; i <= n; ++i)
    	{
    		mp[b[c[i]]]++; 
    	}
    	for (int i = 1; i <= n; ++i)
    	{
    		ans += mp[a[i]];
    	}
    	cout<<ans;
    	return 0; 
    }
    
    • 0
      @ 2024-10-2 9:37:09

      #include<iostream>

      #define int long long

      using namespace std;

      const int N = 1e5 +10;

      int a[N],b[N],c[N],n,m,sum;

      signed main(){

      cin>>n;

      for(int i = 1;i<=n;i++){

      cin>>m;

      a[m]++;

      }

      for(int i = 1;i<=n;i++) cin>>b[i];

      for(int i = 1;i<=n;i++){

      cin>>m;

      sum+=a[b[m]];

      }

      cout<<sum;

      return 0;

      }

      • 0

        赛时代码:

        //t1 nest rp+=INF
        #include<bits/stdc++.h>
        using namespace std;
        
        const int N=1e5+10;
        int n,a[N],b[N],c[N],f[N];
        long long ans;
        
        int main()
        {
        //	freopen("nest.in","r",stdin);
        //	freopen("nest.out","w",stdout);
        	scanf("%d",&n);
        	for(int i=1;i<=n;++i)
        	{
        		scanf("%d",&a[i]);
        		f[a[i]]++;
        	}
        	for(int i=1;i<=n;++i)
        	{
        		scanf("%d",&b[i]);
        	}
        	for(int i=1;i<=n;++i)
        	{
        		scanf("%d",&c[i]);
        		ans+=f[b[c[i]]];
        	}
        	printf("%lld",ans);
        //	fclose(stdin);
        //	fclose(stdout);
        	return 0;
        }
        
        • 1

        信息

        ID
        3190
        时间
        1000ms
        内存
        256MiB
        难度
        8
        标签
        (无)
        递交数
        315
        已通过
        41
        上传者