diff --git a/2017/AUG.md b/2017/AUG.md index d2640c7..805b824 100644 --- a/2017/AUG.md +++ b/2017/AUG.md @@ -12,7 +12,7 @@ | [AUG17](https://www.codechef.com/AUG17) | [RAINBOWA](https://www.codechef.com/AUG17/problems/RAINBOWA) | ★★ | | [![image](../img/GH.png)](AUG/AUG17/RAINBOWA/RAINBOWA.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14909134) (100 pts) [![image](../img/AC.png)](#) | [![image](../img/GH.png)](AUG/AUG17/RAINBOWA/RAINBOWA.java) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14859923) (100 pts) [![image](../img/AC.png)](#) | | | [AUG17](https://www.codechef.com/AUG17) | [CHEFMOVR](https://www.codechef.com/AUG17/problems/CHEFMOVR) | ★★ | | | | | | [AUG17](https://www.codechef.com/AUG17) | [GCAC](https://www.codechef.com/AUG17/problems/GCAC) | ★★★ | | [![image](../img/GH.png)](AUG/AUG17/GCAC/GCAC.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14947059) (100 pts) [![image](../img/AC.png)](#) | | | -| [AUG17](https://www.codechef.com/AUG17) | [PALINGAM](https://www.codechef.com/AUG17/problems/PALINGAM) | ★★★ | | [![image](../img/GH.png)](AUG/AUG17/PALINGAM/PALINGAM.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14908284) (100 pts) [![image](../img/AC.png)](#) | | | +| [AUG17](https://www.codechef.com/AUG17) | [PALINGAM](https://www.codechef.com/AUG17/problems/PALINGAM) | ★★★ | | [![image](../img/GH.png)](AUG/AUG17/PALINGAM/PALINGAM.cpp)  [![image](../img/CC.png)](https://www.codechef.com/viewsolution/14908284) (100 pts) [![image](../img/AC.png)](#) | | [![image](../img/GH.png)](AUG/AUG16/PALINGAM/PALINGAM.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15596349) (100 pts) [![image](../img/AC.png)](#) | | [AUG17](https://www.codechef.com/AUG17) | [CHEFFA](https://www.codechef.com/AUG17/problems/CHEFFA) | ★★★★ | | | | | | [AUG17](https://www.codechef.com/AUG17) | [STRINGRA](https://www.codechef.com/AUG17/problems/STRINGRA) | ★★★★ | | | | | | [AUG17](https://www.codechef.com/AUG17) | [MATDW](https://www.codechef.com/AUG17/problems/MATDW) | ★★★★ | | | | | @@ -26,7 +26,7 @@ | Contest | Problem | [ECR](#ecr) | C | C++ | Java | Python | |:--------------|:----------------:|:----------------:|:----------------:|:----------------:|:-----------------:|:-----------------:| | [COOK85](https://www.codechef.com/COOK85) | [ELEVSTRS](https://www.codechef.com/COOK85/problems/ELEVSTRS) | ★★ | | [![image](../img/GH.png)](AUG/COOK85/ELEVSTRS/ELEVSTRS.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15044633) (100 pts) [![image](../img/AC.png)](#) | | | -| [COOK85](https://www.codechef.com/COOK85) | [OBTTRNGL](https://www.codechef.com/COOK85/problems/OBTTRNGL) | ★★★ | | [![image](../img/GH.png)](AUG/COOK85/OBTTRNGL/OBTTRNGL.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15051769) (100 pts) [![image](../img/AC.png)](#) | | | +| [COOK85](https://www.codechef.com/COOK85) | [OBTTRNGL](https://www.codechef.com/COOK85/problems/OBTTRNGL) | ★★★ | | [![image](../img/GH.png)](AUG/COOK85/OBTTRNGL/OBTTRNGL.cpp) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15051769) (100 pts) [![image](../img/AC.png)](#) | | [![image](../img/GH.png)](AUG/COOK85/OBTTRNGL/OBTTRNGL.py) [![image](../img/CC.png)](https://www.codechef.com/viewsolution/15057276) (100 pts) [![image](../img/AC.png)](#) | | [COOK85](https://www.codechef.com/COOK85) | [MTRXMOD](https://www.codechef.com/COOK85/problems/MTRXMOD) | ★★★★ | | | | | | [COOK85](https://www.codechef.com/COOK85) | [GAMSTICK](https://www.codechef.com/COOK85/problems/GAMSTICK) | ★★★★★ | | | | | | [COOK85](https://www.codechef.com/COOK85) | [TRCNTCT](https://www.codechef.com/COOK85/problems/TRCNTCT) | ★★★★★ | | | | | diff --git a/2017/AUG/AUG17/PALINGAM/PALINGAM.py b/2017/AUG/AUG17/PALINGAM/PALINGAM.py new file mode 100644 index 0000000..640bb88 --- /dev/null +++ b/2017/AUG/AUG17/PALINGAM/PALINGAM.py @@ -0,0 +1,28 @@ +t = int(input()) +while t > 0: + a = input() + b = input() + la = list() + lb = list() + la = 26 * [0] + lb = 26 * [0] + sa = set() + sb = set() + for i in range(len(a)): + la[ord(a[i]) - ord('a')] += 1 + lb[ord(b[i]) - ord('a')] += 1 + sa.add(a[i]) + sb.add(b[i]) + p = int(1) + for i in range(26): + if la[i] > 1 and lb[i] == 0: + p = 0 + print("A") + break + elif sb.issubset(sa) and not(sb.issuperset(sa)): + print("A") + p = 0 + break + if p == 1: + print("B") + t -= 1 diff --git a/2017/AUG/COOK85/OBTTRNGL/OBTTRNGL.py b/2017/AUG/COOK85/OBTTRNGL/OBTTRNGL.py new file mode 100644 index 0000000..3ce3bde --- /dev/null +++ b/2017/AUG/COOK85/OBTTRNGL/OBTTRNGL.py @@ -0,0 +1,15 @@ +t = int(input()) +for i in range(t): + n,x,y = map(int ,input().split()) + a = min(x,y) + b = max(x,y) + b = b - a + 1 + a = 1 + if (n%2 == 0 and n/2 == b - a) or (b - a == 1 or b == n): + print("0") + else: + if b > n/2 + 1: + print(n - b) + elif b < n/2 + 1: + print(b - 2) + diff --git a/2017/OCT/OCT17/CHEFGP.py b/2017/OCT/OCT17/CHEFGP.py new file mode 100644 index 0000000..00a2679 --- /dev/null +++ b/2017/OCT/OCT17/CHEFGP.py @@ -0,0 +1,64 @@ +t = int(input()) +while t > 0: + s = input() + w = "" + x, y = map(int, input().split()) + na = s.count("a") + nb = s.count("b") + if na > nb: + smax = "a" + smin = "b" + else: + smax = "b" + smin = "a" + tamp = na + na = nb + nb = tamp + tamp = x + x = y + y = tamp + h = "" + xa = na/x + mini = int(min(xa, nb)) + h = h + smax * x + h = h + smin + w = w + h * mini + ra = na - mini * x + rb = nb - mini + if ra < x and ra > 0: + w = w + smax * ra + if rb != 0: + w = w + smin + rb -= 1; + elif ra >= x: + k = x + i = 0 + while i < ra: + if k == 0: + w = w + "*" + k = x + else: + w = w + smax + k -= 1 + i += 1 + if rb < y and rb > 0: + w = w + smin * rb + elif rb >= y: + if smin == "b": + c = 'b' + else: + c = 'a' + l = len(w) + i = int(1) + while rb > 0 and i < l: + if w[i] != c: + w = w[:i] + smin + w[i:] + i += 1 + rb -= 1 + l += 1 + else: + i += 1 + i += 1 + print(w) + t -= 1 +