From f6d4070d028ca78661df13a179ec42540f14af65 Mon Sep 17 00:00:00 2001 From: rajat1433 <32011988+rajat1433@users.noreply.github.com> Date: Wed, 9 Oct 2019 14:25:53 +0530 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=95=9A=20Citrix=20IIT=20G=202019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🕚 Citrix IIT G 2019 --- special binary string.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 special binary string.cpp diff --git a/special binary string.cpp b/special binary string.cpp new file mode 100644 index 0000000..27d3d79 --- /dev/null +++ b/special binary string.cpp @@ -0,0 +1,36 @@ +/* + +CITRIX IIT Guwahti 2019 + +Special binary strings are binary strings with the following two properties: + +The number of 0's is equal to the number of 1's. +Every prefix of the binary string has at least as many 1's as 0's. +Given a special string S, a move consists of choosing two consecutive, non-empty, special substrings of S, and swapping them. (Two strings are consecutive if the last character of the first string is exactly one index before the first character of the second string.) + +At the end of any number of moves, what is the lexicographically largest resulting string possible? + +*/ + + string makeLargestSpecial(string S) { + int i=0, count=0; + vector res; + for(int j=0;j()); + + string r = ""; + for(auto s:res){ + r+=s; + } + return r; + } From 38f93f0d208f9a6a1115779839bb4a682f13813c Mon Sep 17 00:00:00 2001 From: rajat1433 <32011988+rajat1433@users.noreply.github.com> Date: Wed, 9 Oct 2019 14:36:41 +0530 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=8C=B2=20Samsung=20Bangalore=20NITA?= =?UTF-8?q?=202019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wormholes.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 wormholes.cpp diff --git a/wormholes.cpp b/wormholes.cpp new file mode 100644 index 0000000..23bc4b3 --- /dev/null +++ b/wormholes.cpp @@ -0,0 +1,61 @@ +/* +Samsung Bangalore NIT Agartala 2019 + +There is one spaceship. X and Y co-odinate of source of spaceship and destination spaceship is given. +There are N number of warmholes; each warmhole has 5 values. +First 2 values are starting co-ordinate of warmhole and after that value no. 3 and 4 represents ending +co-ordinate of warmhole and last 5th value is represents cost to pass through this warmhole. +Now these warmholes are bi-directional. Now the to go from (x1,y1) to (x2,y2) is abs(x1-x2)+abs(y1-y2). +The main problem here is to find minimum distance to reach spaceship from source to destination +co-ordinate using any number of warm-hole. +It is ok if you wont use any warmhole. +*/ + +#include +using namespace std; + +int ans,mask[10],w[10][5],n; + +int distance(int sx,int sy,int dx,int dy) { + int xd=(sx>dx)?(sx-dx):(dx-sx); + int yd=(sy>dy)?(sy-dy):(dy-sy); + return (xd+yd); +} + +void cal(int sx,int sy,int dx,int dy,int dis) { + + ans=min(ans,distance(sx,sy,dx,dy)+dis); + + for(int i=0;i>t; + while(t--) { + + cin>>n; + int sx,sy,dx,dy; + cin>>sx>>sy>>dx>>dy; + + for(int i=0;i>w[i][j]; + } + } + ans=999999; + cal(sx,sy,dx,dy,0); + cout<<"#"< Date: Wed, 9 Oct 2019 15:34:56 +0530 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=95=9A=20Citrix=20IIT=20G=202019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- special binary string.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/special binary string.cpp b/special binary string.cpp index 27d3d79..1a9e640 100644 --- a/special binary string.cpp +++ b/special binary string.cpp @@ -6,10 +6,15 @@ Special binary strings are binary strings with the following two properties: The number of 0's is equal to the number of 1's. Every prefix of the binary string has at least as many 1's as 0's. -Given a special string S, a move consists of choosing two consecutive, non-empty, special substrings of S, and swapping them. (Two strings are consecutive if the last character of the first string is exactly one index before the first character of the second string.) +Given a special string S, a move consists of choosing two consecutive, non-empty, +special substrings of S, and swapping them. (Two strings are consecutive if the last character +of the first string is exactly one index before the first character of the second string.) At the end of any number of moves, what is the lexicographically largest resulting string possible? +Solution: +Recursively try to find the lexicographically largest strings and sort them using a comparator function. + */ string makeLargestSpecial(string S) {