满江红求助
查看原帖
满江红求助
1096037
TTdd110517楼主2024/5/2 20:10
#include<bits/stdc++.h>
using namespace std;
struct s
{
	int d;
	int ci;
	int shun;
}p[10005];
map<int,int>w;  
int g[10005]; 
int main()
{
   int n,c;
   cin>>n>>c;
   for(int i=1;i<=n;i++)
  {
  	 int x;
  	 cin>>x;
	 if(w.find(x)==w.end())
	 {
	 	p[i].shun=i;
	 	g[x]=i;
	 }
	 else 
	 {
	 	p[i].shun=g[x];
	 }
  	 w[x]++;
  	 p[i].d=x;
  }
   for(auto x:w)
   {
   	for(int i=1;i<=n;i++)
   	{
   	  if(x.first==p[i].d)
   	  p[i].ci=x.second;
   }
   }
  for(int i=1;i<=n;i++)
     	{
     		cout<<p[i].d<<" "<<p[i].ci<<" "<<p[i].shun<<endl;
     	}
	return 0;
}

为什么过不了?

2024/5/2 20:10
加载中...