1107A - Digits Sequence Dividing - CodeForces Solution


greedy strings *900

Please click on ads to support us..

Python Code:


for _ in range(int(input())):
	n = int(input())
	s = input()
	s1 = int(s[0])
	s2 = int(s[1:])
	if s1 < s2:
		print('YES')
		print(2)
		print(s1, s2)
	else:
		print('NO')

C++ Code:

#include<bits/stdc++.h>
using namespace std;

int main()
{
	int t;
	cin>>t;
	while(t-->0)
	{
        long long int n;
        cin>>n;
        string s;
        cin>>s;
        if(s.size()==2 and s[0]>=s[1])
        {
            cout<<"NO"<<"\n";
            continue;
        }
        cout<<"YES\n2\n";
        cout<<s.substr(0,1)<<" "<<s.substr(1)<<"\n";
	}
	return 0;
}


Comments

Submit
0 Comments
More Questions

1613B - Absent Remainder
1536B - Prinzessin der Verurteilung
1699B - Almost Ternary Matrix
1545A - AquaMoon and Strange Sort
538B - Quasi Binary
424A - Squats
1703A - YES or YES
494A - Treasure
48B - Land Lot
835A - Key races
1622C - Set or Decrease
1682A - Palindromic Indices
903C - Boxes Packing
887A - Div 64
755B - PolandBall and Game
808B - Average Sleep Time
1515E - Phoenix and Computers
1552B - Running for Gold
994A - Fingerprints
1221C - Perfect Team
1709C - Recover an RBS
378A - Playing with Dice
248B - Chilly Willy
1709B - Also Try Minecraft
1418A - Buying Torches
131C - The World is a Theatre
1696A - NIT orz
1178D - Prime Graph
1711D - Rain
534A - Exam