-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBinary-Path.cpp
More file actions
77 lines (70 loc) · 1.51 KB
/
Binary-Path.cpp
File metadata and controls
77 lines (70 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void solve() {
ll n;
cin>>n;
string s1,s2;
cin>>s1;
cin>>s2;
map<string,int> mp;
for(int i=0;i<n;i++)
{
string temp=s1.substr(0,i+1)+s2.substr(i,n-i);
mp[temp]++;
}
cout<<mp.begin()->first<<endl;
cout<<mp.begin()->second<<endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
// #include<bits/stdc++.h>
// using namespace std;
// #define ll long long int
// void dfs(vector<string> &v,ll i,ll j,vector<vector<int>> &vis,map<string,int> &m,string& s){
// if(i<0 || j<0 || i>=2 || j>=v[0].size() || vis[i][j]==1){
// return;
// }
// if(i==1 && j==v[0].size()-1){
// m[s]++;
// return;
// }
// vis[i][j]=1;
// s+=v[i][j];
// dfs(v,i+1,j,vis,m,s);
// dfs(v,i,j+1,vis,m,s);
// s.pop_back();
// vis[i][j]=0;
// }
// void solve() {
// ll n;
// cin>>n;
// vector<string> v(2);
// for(ll i=0;i<2;i++){
// cin>>v[i];
// }
// map<string,int> m;
// vector<vector<int>> vis(2,vector<int>(n,0));
// string s="";
// dfs(v,0,0,vis,m,s);
// cout<<m.begin()->first<<v[1][n-1]<<endl;
// cout<<m.begin()->second<<endl;
// }
// int main() {
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
// ll t;
// cin >> t;
// while (t--) {
// solve();
// }
// return 0;
// }