2 solutions

  • 0
    @ 2023-2-2 21:10:03

    vector 使用

    #include<set>
    #include<map>
    #include<vector>
    using namespace std;
    vector<int> a[100001];
    int main()
    {
    	int x,y,n;
    	char b[6];
    	cin>>n;
    	while(n--)
    	{
    		cin>>b;
    		if(b[0]=='A')
    		{
    			cin>>x>>y;
    			a[x].push_back(y);//将y存入容器数组 
    		}
    		if(b[0]=='Q')
    		{
    			cin>>x>>y;
    			if(a[x].size()<y) //编号为x的帖子总的回复数小于y 
    			 cout<<-1<<endl;
    			else cout<<a[x][y-1]<<endl;//否则输出第y个回复的人的ID 
    		}
    	}
    	return 0;
     } 
     
    

    Information

    ID
    825
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    2
    Tags
    # Submissions
    41
    Accepted
    27
    Uploaded By