2 solutions

  • 0
    @ 2026-11-11 20:57:33
    #include<bits/stdc++.h>
    using namespace std;
    const int N=210;
    string s[N];
    int main()
    {
    	int t;
    	cin>>t;
    	while(t--)
    	{
    		int n;
    		cin>>n;
    		for(int i=1;i<=n;i++)
    		{
    			cin>>s[i];
    		}
    		sort(s+1,s+n+1);
    		bool st=true;
    		string s1; 
    		for(int i=1;i<=n;i++)
    		{
    			s1=s1+s[i];
    		}
    		for(int i=0;i+1<s1.size();i++)
    		{
    			if(s1[i]>s1[i+1]) st=false;
    		}
    		if(st) cout<<1<<endl;
    		else cout<<0<<endl;
    	}
    	return 0; 
    } 
    

    Information

    ID
    2216
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    9
    Tags
    # Submissions
    13
    Accepted
    5
    Uploaded By