3 solutions

  • -1
    @ 2024-4-21 15:59:55
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	string a[5001][2];
    	int n;
    	string name;
    	cin>>n;
    	for(int i=1;i<=n;i++){
    		cin>>a[i][1]>>a[i][2];
    	}
    	for(int i=1;i<=n;i++){
    		if(a[i][1]!="0-0"){
    			name=a[i][1];
    			cout<<name<<" ";
    		}
    		else continue;
    		for(int j=i;j<=n;j++){
    			if(a[j][1]==name){
    				cout<<a[j][2]<<" ";				
    				a[j][1]="0-0";
    			}
    		}
    		
    		cout<<endl;
    	}
    	return 0;
    }
    
    

    Information

    ID
    154
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    (None)
    # Submissions
    47
    Accepted
    17
    Uploaded By