3 solutions

  • 1
    @ 2022-3-29 16:38:16
    #include <bits/stdc++.h>
    using namespace std;
    
    struct loc{
        vector<int> num;
    };
    
    int main(){
        int n,m,x,y;
        cin>>n>>m;
        loc a[n];
        for(int i = 0 ; i < m ; i++){
        	cin>>x>>y;
        	a[x-1].num.push_back(y);
    	}
    	for(int i = 0 ; i < n ; i++){
    		sort(a[i].num.begin(),a[i].num.end());
    	}
        for(int i = 0 ; i < n ; i++){
        	int size = a[i].num.size();
        	cout<<size<<" ";
            for(int j = 0 ; j < size; j++){
                cout<<(a[i].num)[j]<<" ";
            }
            cout<<endl;
        }
        return 0;
    }
    

    Information

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