prompt
string
response
string
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; const int m = 1000000007; int main() { string str, temp; cin >> str; map<string, int> mapi; int len = str.length(); mapi[str] = 1; str.append(str); for (int i = 0; i < len; i++) { temp = str.substr(i, len); if (mapi.count(temp) == 0) { mapi[temp]...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = raw_input() if len(set(s)) == 1: print "1" exit() elif len(set(s)) == len(s): print len(s) exit() l = [] l.append(s) count = 0 for e in s[::-1]: temp = e + s[:-1] if not temp in l : l.append(temp) count += 1 s = temp print count+1
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
"use strict"; Array.prototype.contains = function(el){ return this.indexOf(el) > -1; }; var rotateArray = function rotateArray(arr){ arr.unshift(arr.pop()); return arr; }; print(function(input){ input = input.split(''); var len = input.length; var arr = []; var i = 0; var count = 0; while (i < len...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = raw_input() ans = 1; new = s[:] n = len(s); flag = 1; while(new != s or flag): flag = 0; new = new[-1] + new[:n-1] if(new != s): ans+=1;1 print ans
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import sys sys.setrecursionlimit(99999999) i = lambda: sys.stdin.readline().strip() ii = lambda: map(int, i().split()) s = i() taken = {} acc = 0 for e in xrange(len(s)): s_ = s[e:] + s[:e] if s_ not in taken: taken[s_] = True acc += 1 print acc
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
word = list(input()) comb = [] for i in range(len(word)): l = word[-1] del word[-1] word = [l] + word str1 = ''.join(word) comb.append(str1) print(len(set(comb)))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.PrintWriter; import java.util.*; import java.util.Arrays ; public class Test{ static int pos = 0 ; static int arr[] ; static LinkedList l1 = new LinkedList() ; static void find(int p ,char[]x,int put[],String s){ int c= 0 ; for (int i = 0; i < s.length(); i++) { if(x...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
from collections import deque as deque if __name__ =='__main__': s = raw_input().strip() l = deque([x for x in s]) st = set() for i in range(len(s)): st.add(''.join(l)) l.append(l.popleft()) print len(st)
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = raw_input() ans = len(s) for i in range(1,(len(s)/2)+1): ns = s[0:i] news = (len(s)/len(ns))*ns if news == s: ans = len(ns) break print ans
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin >> s; long long n = s.size(); set<string> st; for (long long i = 0; i < n; i++) { string f; for (long long j = i; j < n; j++) f += s[j]; for (long long j = 0; j < i;...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { static final int MAXN = 500507; static void rev(char arr[], int l, int r) { for (int w = l; w < r; w++) { char t = arr[w]; arr[w] = arr[r]; arr[r] = t; } } public static void main(S...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.IOException; import java.io.InputStream; import java.util.HashSet; import java.util.InputMismatchException; public class CfA{ void solve() { HashSet<String> set = new HashSet<>(); String s = ns(); int l = s.length(); while(l-->0) { set.add(s); s = s.substring(1)+s.charAt(0); } Sys...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() l = len(s) for x in range(1, 1+l//2): step = l//x if s == s[:x]*step: print (x) break else: print (l)
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input() f = set([s]) for i in range(len(s)): f.add(s[i:] + s[:i]) print(len(f))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.StringTokenizer; import java.util.Set; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /**...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author shankyty */ public class Main { public static void main(String[] args) { InputStream ...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s=raw_input() S=set() for i in range(len(s)): S.add(s[i:]+s[:i]) print len(S)
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.*; import java.util.*; public class A { public static void solution(BufferedReader reader, PrintWriter writer) throws IOException { In in = new In(reader); Out out = new Out(writer); String s = in.next(); HashSet<String> set = new HashSet<String>(); ...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int result; string input; cin >> input; set<string> sinput; sinput.insert(input); for (int i = input.size() - 1; i >= 0; --i) { input = input[input.size() - 1] + input; input.pop_back(); sinput.insert(...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; int n = a.length(); set<string> s; for (int i = 0; i < n; i++) { string t = ""; for (int j = i; j < n; j++) t += a[j]; for (int j = 0; j < i; j++) t += a[j]; s.insert(t); } cout << s.size() << endl; return 0; ...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
def fun(w): a=[] if(len(w)==1): return 1 elif(len(w)==2): if(w[0]==w[1]): return 1 else: return 2 else: for j in range(len(w)): if((w in a) == False): a.append(w) w=w[len(w)-1]+w[0:len(w)-1] return l...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
a = input() print(len(set([a[x:] + a[:x] for x in range ( len(a) ) ] ) ) )
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
def main(): s = input() n = len(s) d = {s: 0} for _ in range(n - 1): s = s[n - 1] + s[:(n - 1)] d[s] = 0 print(len(d)) if __name__ == '__main__': main()
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; if (s.size() == 1) { cout << 1 << endl; return 0; } map<string, int> p; int counter = 1; p[s]++; string o; o += s[s.size() - 1]; o += s.substr(0, s.size() - 1); if (p[o] > 0) ; else { p[o]++; count...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; set<string> st; string s; void f(string& s) { char temp = s[s.size() - 1]; for (int i = s.size() - 1; i > 0; --i) s[i] = s[i - 1]; s[0] = temp; } int main() { cin >> s; st.insert(s); for (int i = 0; i < s.size(); ++i) { f(s); st.insert(s); } cout << ...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import sys import math #sz, x = [int(i) for i in input().split()] #ar = [int(i) for i in input().split()] st=str(input()) mp={} for i in range(len(st)+2): st=st[1:]+st[0] #print(st) mp[st]=1 print(len(mp))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
def extend_word (word): aux = word word_len = len(word) new_word = "" words = set() while (True): for i in range(1, word_len): new_word = new_word + aux[i] new_word = new_word + aux[0] if (new_word == word): break aux = new_word wor...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s1 = input() s2 = s1 count = 1 for i in range(len(s1)-1): s2 = s2[-1] + s2[:-1] if s2 != s1: count += 1 else: break print(count)
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int Q, N, M, K, L; set<string> s; string S; int main() { cin >> S; int ret = 0; for (int i = 0; i < S.size(); i++) { rotate(S.begin(), S.begin() + 1, S.end()); if (s.find(S) == s.end()) ret++; s.insert(S); } cout << ret; cin >> N; }
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; int main() { int i, j; set<string> s; string s1; cin >> s1; s.insert(s1); for (j = 1; j < s1.size(); j++) { for (i = s1.size() - 1; i > 0; i--) swap(s1[i], s1[i - 1]); s.insert(s1); } cout << s.size() << endl; s.clear(); return 0; }
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.*; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; public class CodeForcesA { private final static String FILENAME; private final static String PATH; static { FILENAME = ""; if (!FILENAME.isEmpty()) { PATH =...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import sys string = input() string2 = [] string2.append(string) lastword = string cnt = 1 for ch in range(len(string)): word = lastword[-1] + lastword[0:-1] if word not in string2: string2.append(word) cnt += 1 lastword = word print(cnt)
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s=input() ss=[] for i in range(len(s)): ss.append(s[i:]+s[:i]) ss.sort() s=ss[0] res=1 for item in ss: if item!=s: res+=1 s=item print(res)
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class CyclicShift { public static void main(String[] args) { try (Scanner scanner = new Scanner(System.in)) { System.out.println(countDistinctWords(scanner.nextLine().toCharArray())); } } privat...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.util.Scanner; import java.util.HashMap; public class CiklicheskieSdvigi{ public static void main(String[] args) { Scanner input = new Scanner(System.in); HashMap<String, String> stroki = new HashMap<String, String>(); String s = input.nextLine(); stroki.put(s, s); for (int i = 0; i < ...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.TreeSet; public class A { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); String s = sc....
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; template <typename TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << "=" << h << "\n"; } template <typename TH, typename... TA> void _dbg(const char *sdbg, TH h, TA... t) { while (*sdbg != ',') { cerr << *sdbg++; } cerr << "=" << h << ","; _dbg(sdbg + 1,...
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
s = input().strip() st = set() for i in range(51): st.add(s) s = s[-1]+s[:-1] print(len(st))
Problem: Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word. Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last c...
#include <bits/stdc++.h> using namespace std; bool isPrime(long long a) { if (a == 1 || (a > 2 && a % 2 == 0)) return 0; for (long long i = 3; i * i <= a; i += 2) if (a % i == 0) return 0; return 1; } long long save[999999]; long long a[999999]; long long b[99999]; char ch[99999]; int main() { string s; c...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class C399 { public static void main(String[] args) { FS scan = new FS(System.in); int N = scan.nextInt(), K = scan.nextInt(), ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.*; import java.util.*; public class First { public static void main(String[] args) throws Exception { int n=i(); int k=i(); int x=i(); int[] a=new int[1025]; for( int i=0 ; i<n ; i++ ){ a[i()]++; } int f=0; int[] b=new int[a.length]; for( int i=0 ; i<k ; i++ ){ f=0; int j=0;...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Div2_399C { public static void main(String[] args) throws IOException { new Div2_399C().execute(); } void execute() throws IOException { BufferedReader reader = new Buffe...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.util.*; public class XOR { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int rep = sc.nextInt(); int fav = sc.nextInt(); ArrayList<Integer> list = new ArrayList<>(n); for( int ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; inline int _Int() { int x; scanf("%d", &x); return x; } long long int bigMod(long long int A, long long int P, int M) { long long int R = 1; for (A %= M; P; P >>= 1) { if (P & 1) R = (R * A) % M; A = (A * A) % M; } return R; } long long int bigMul(long...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.*; import java.math.*; import java.util.*; public class C { final static int MOD = 1000000007; public static void main(String[] args) throws Exception { FastReader in = new FastReader(System.in); //Scanner in = new Scanner(new File("C:\\Users\\hizac\\Documents\\input.txt")); int n = in.nextInt(...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:16777216") using namespace std; bool rs(string* s) { char buf[200001]; again: if (gets(buf)) { if (buf[0] == '\n' || buf[0] == 0) goto again; *s = string(buf); return true; } else return false; } bool rtok(string* s) { char buf[200001]; ag...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.*; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public class Solution { private static String inputFilename = "src/input.txt"; private static String outputFilename = "src/output.txt"; private BufferedReader in; private StringTokenizer line; pr...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.util.HashMap; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.io.Writer; i...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 5; long long arr[N]; long long cnt[N]; int32_t main() { long long n, k, x; cin >> n >> k >> x; for (long long i = 0; i < n; i++) { cin >> arr[i]; cnt[arr[i]]++; } for (long long i = 0; i < k; i++) { long long temp[2000]; f...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.math.BigDecimal; import java.math.BigInteger; import java.nio.ByteBuffer; import java.util.Arra...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); ; long long mini, maxi, i, n, k, x, m, count = 0, no, hlf; cin >> n >> k >> x; long long arr[n], dp[1025], dpcp[1025]; memset(dp, 0, sizeof(dp)); memset(dpcp, 0, sizeof(dpcp)); for (i = 0; i < n; i++) { cin >> m;...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; int A[2222][2]; int main() { int n, k, x, a, c, s, i; bool j; scanf("%d%d%d", &n, &k, &x); for (i = 0; i < n; i++) { scanf("%d", &a); A[a][0]++; } for (j = 0; k--; j = !j) { for (i = s = 0; i <= 2047; i++) { c = (s + A[i][j] + 1) / 2 - (s + 1) ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static void solve(int[] fre, int n, int k, int x){ int[] tmp=new int[1024]; for (int i=0;i<k;i++) { for (int j=0;j<1024;j++) ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342; const int MR = 1e5 + 10; int t[MR]; map<vector<int>, int> M; int main() { int n, k, x; scanf("%d%d%d", &n, &k, &x); for (int i = 0; i < (n); ++i) sca...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; int n, k, x, nums[100100]; int cont[1100], aux[1100]; int main() { scanf("%d %d %d", &n, &k, &x); for (int i = 0; i < n; i++) { scanf("%d", &nums[i]); cont[nums[i]]++; } for (int i = 0; i < k; i++) { bool ceil = true; for (int j = 0; j < 1100; j++) ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashMap; import java.util.StringTokenizer; public class Main { private static int N, K, X; private static int[] array; private static HashMap<node, Integer> map = new HashMap<node, ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; struct less_key { bool operator()(pair<int64_t, int64_t> p1, pair<int64_t, int64_t> p2) { return (p1.first < p2.first) || (p1.second < p2.second); } }; struct pair_hash { std::size_t operator()(const pair<int64_t, int64_t>& k) const { return static_cast<size_t...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long expo(long long base, long long pow) { long long ans = 1; while (pow != 0) { if (pow & 1 == 1) { ans = ans * base; ans = ans % m...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; int i, j, n, m, a, b, c, d, op, maxi, mini, mij, ls, ld, ul, timp, k, l, r, rasp; int dp[2][100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> a >> b; for (i = 1; i <= n; i++) { cin >> d; dp[0][d]++; } for (i = 1; i <=...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000 + 100, INF = 1e8; int n, k, x, num[2][MAXN], a, mi, ma; int main() { cin >> n >> k >> x; mi = INF; ma = -INF; for (int i = 0; i < n; ++i) { scanf("%d", &a); ++num[0][a]; mi = min(mi, a); ma = max(ma, a); } for (int i = 0; i ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
from sys import stdin from copy import copy ceil1 = lambda a, b: (a + b - 1) // b rints = lambda: [int(x) for x in stdin.readline().split()] n, k, x = rints() a, mem = rints(), [0] * 1024 for i in a: mem[i] += 1 for i in range(k): tem, lst = [0] * 1024, 0 for j in range(1024): tem[j ^ x] += ceil1(...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; int freq[1025], a[1025]; int main() { int n, k, x, y; scanf("%d %d %d", &n, &k, &x); for (int i = 0; i < n; i++) { scanf("%d", &y); freq[y]++; } for (int i = 0; i < k; i++) { for (int i = 0; i <= 1024; i++) a[i] = freq[i]; bool left = true; for...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.*; import java.util.StringTokenizer; public class C768 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); StringTokeni...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import itertools from fractions import gcd from math import sqrt from bisect import bisect_left import heapq from collections import deque from itertools import combinations as C def Ls(): return list(raw_input()) def get(a): return map(a , raw_input().split()) def Int(): return int(raw_input()) def Str(): return ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
n,k,x=map(int,input().split()) r=list(map(int,input().split())) k%=64 while k: k-=1 r.sort() for i in range(0,n,2):#alternate r[i]^=x print(max(r),min(r))
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.*; import java.util.*; import java.math.BigInteger; import java.util.Map.Entry; import static java.lang.Math.*; public class C extends PrintWriter { void run() { int n = nextInt(), k = nextInt(), x = nextInt(), m = 1024; int[] a = new int[m], b = new int[m], c; for (int i...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; template <class Ty> inline void rd(Ty& res) { res = 0; char c; bool flag = false; while (c = getchar(), c != '-' && (c < '0' || c > '9')) ; if (c == '-') flag = true, c = getchar(); do res = res * 10 + (c ^ 48); while (c = getchar(), c >= '0' && c <= '9');...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.*; import java.util.*; import java.math.*; public class C { public static void main(String[] args) throws IOException { /**/ Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in))); /*/ Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; int n, k, x; int a, freq[2][1025]; int main() { scanf("%d%d%d", &n, &k, &x); for (int i = 0; i < n; i++) { scanf("%d", &a); freq[0][a]++; } int rIdx = 0; for (int i = 0; i < k; i++, rIdx = 1 - rIdx) { int tot = 0; memset(freq[1 - rIdx], 0, sizeof(f...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.*; import java.util.*; public class C { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader( new InputStreamReader(System.in) ); StringTokenizer st = new StringTokenizer( br.readLine() ); int n = Integer.parseInt( st.nextToken() ); int k = Intege...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.util.*; import java.io.*; /** * * @author umang * */ public class ProblemF { public static int mod = (int) (1e9+9); public static ArrayList<Integer>[] g; public static void main(String[] args) { new Thread(null ,new Runnable(){ public void run(){ ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; int n; int arr[2][1050]; int main() { int k, x; scanf("%d%d%d", &n, &k, &x); for (int i = 0; i < (n); i++) { int v; scanf("%d", &v); arr[1][v]++; } while (k--) { int odd = 1; for (int i = 0; i < (1024); i++) { arr[0][i] = arr[1][i]; ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; const int N = 1024; int cnt[N]; int a[N][2]; int main() { int n, k, x; scanf("%d %d %d", &n, &k, &x); memset(cnt, 0, sizeof cnt); for (int i = 0; i < n; ++i) { int foo; scanf("%d", &foo); ++cnt[foo]; } while (k--) { for (int i = 0, j = 0; i < N; ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.util.*; public class XOR { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int rep = sc.nextInt(); int fav = sc.nextInt(); ArrayList<Integer> list = new ArrayList<>(n); for( int i...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; const int max_n = 1033, log_n = 32, max_m = 111, mod = 1000000007, inf = 1011111111, p = 997; int n, k, x, cnt[2][max_n]; int main() { scanf("%d%d%d", &n, &k, &x); for (int i = 0; i < n; ++i) { int a; scanf("%d", &a); cnt[0][a]++; } int f = 0, ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.*; import java.util.*; public class Main { InputReader scn; PrintWriter out; String INPUT = ""; void solve() { int n = scn.nextInt(), k = scn.nextInt(), x = scn.nextInt(); int[] fr = new int[1 << 10]; for (int i = 0; i < n; i++) { int z = scn.nextInt(); fr[z]++; } for(int i = 1; i ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; template <typename T> inline void read(T &x) { x = 0; int f = 1; char ch = getchar(); while ((ch < '0' || ch > '9') && ch != '-') ch = getchar(); if (ch == '-') { f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { // your code goes here MyScanner sc =...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
from sys import stdin, stdout def updateList(a,x,n): a.sort() for i in range(0,n,2): a[i]=a[i]^x return a n, k, x = map(int, stdin.readline().rstrip().split()) a = stdin.readline().rstrip().split() a = [int(num) for num in a] aColl=set() aColl.add(tuple(a)) finished=False moves=0 while not fini...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class C399 { public static void main(String[] args) { FS scan = new FS(System.in); int N = scan.nextInt(), K = scan.nextInt(), X = scan.nextInt(); int...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOExcept...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main3 { static long mod = 1000000007L; public static void main(String[] args) { FastScanner scanner = new FastScanner(); int n = scanner.nextInt(); int k = sca...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import sys from random import * from bisect import * #from collections import deque pl=1 from math import gcd,sqrt from copy import * sys.setrecursionlimit(10**5) if pl: input=sys.stdin.readline else: sys.stdin=open('input.txt', 'r') sys.stdout=open('outpt.txt','w') def li(): return [int(xxx) for xxx in input().s...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const long long inf = 1e18; const int Lim = 1e5 + 1e3; const double eps = 1e-10; int a[2][1024]; int p = 0, val; int fn() { for (long long i = 0; i < (long long)(1024); i++) { if (a[p][i] != 0) cout << i << " " << a[p][i] << "\n"; } } int ma...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; template <typename _T> inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; } template <typename _T, typename... args> void _DBG(const char *s, _T x, args... a) { while (*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); } con...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.util.Scanner; public class Main { public static void main(String[] args) { // Write your code here Scanner s=new Scanner(System.in); int n=s.nextInt(),k=s.nextInt(),x=s.nextInt(); int[] prev=new int[1024]; int[] curr=new int[1024]; for(int i=0;i<n;i++) prev[s.nex...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.util.*; public class XOR { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int rep = sc.nextInt(); int fav = sc.nextInt(); ArrayList<Integer> list = new ArrayList<>(n); for( int ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.util.*; public class MyClass { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int k=sc.nextInt(); int x=sc.nextInt(); long[] arr=new long[n]; int freq[] =new int[1100]; int tmp[]=new int[1024]; ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1024; int a[maxn], b[maxn]; int main() { int n, k, x; scanf("%d%d%d", &n, &k, &x); for (int i = 1; i <= n; ++i) { int y; scanf("%d", &y); ++a[y]; } int *now = a, *nxt = b; while (k--) { int sum = 0; memset(nxt, 0, sizeof(a));...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, x; cin >> n >> k >> x; int a[n]; int freq[2001] = {0}; for (int i = 0; i < n; i++) { cin >> a[i]; freq[a[i]]++; } int l = 0; int tmp[2001]; for (int i = 0; i < k; i++) { l = 0; for (int i = 0; i < 2001; i++) tmp[i] = ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, x; scanf("%d%d%d", &n, &k, &x); int a[n + 1], freq[1500] = {0}; for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); ++freq[a[i]]; } while (k--) { int tot = 0, nw[1500] = {0}; for (int i = 0; i < 1500; ++i) { if (!freq[...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; template <class T> ostream& operator<<(ostream& os, const vector<T>& v) { for (T i : v) os << i << ' '; return os; } template <class T> ostream& operator<<(ostream& os, const set<T>& v) { for (T i : v) os << i << ' '; return os; } template <class T, class S> ostream...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
n,k, x = [int(i) for i in input().split()] a=[int(i) for i in input().split()] w=[] i=0 while i< k: a.sort() w = a.copy() for j in range(0, n, 2): a[j]=a[j]^x if n * k > 500000 and min(a) == w[0] and max(a) == w[-1]: break i += 1 print(max(a), min(a))
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int x = sc.nextInt(); int freq[]= new int [1024]; //entering the data in the frequency array ...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; int main() { vector<int> F(1025); int N, K, X; cin >> N >> K >> X; int mi = 100000, ma = 0; for (int i = 0; i < N; ++i) { int n; cin >> n; F[n]++; } for (int i = 0; i < K; ++i) { int id = 0; vector<int> F2(1025); for (int k = 0; k < F.s...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * Created by shirsh.bansal on 20/02/17. */ public class Main { public static void main(String[] args) throws IOException { FastScanner scanner = new FastScanner(); in...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; const double _pi = acos(-1.0); int ar[1110]; int ar2[1110]; int main() { int n, k, x; scanf("%d %d %d", &n, &k, &x); for (int i = 0; i < n; i++) { int a; scanf("%d", &a); ar[a]++; } while (k--) { int c = 0; for (int i = 0; i <= 1100; i++) ar2[i...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
import java.util.*; import java.util.Arrays; public class Solution { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int x = sc.nextInt(); int[] count = new int[1026]; int[] secCount = new int[...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; int n, k, x; int a[100005]; int f[1024]; int temp[1024]; int main() { scanf("%d %d %d", &n, &k, &x); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); f[a[i]]++; } int curr = 0; for (int i = 1; i <= k; i++) { curr = 0; for (int j = 0; j < 1024; j+...
Problem: Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. ...
#include <bits/stdc++.h> using namespace std; const int N = 100000; const int K = 100000; const int X = 1023; int main() { int n, k, x; scanf("%d%d%d", &n, &k, &x); int dp[2][X + 1] = {}; for (int i = 0; i < n; i++) { int v; scanf("%d", &v); dp[0][v]++; } for (int i = 0; i < k; i++) { int c ...