Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
The Power of C# | Hikmat Ahmedov | 1723. Книга Сандро | 15 сен 2022 08:54 | 6 |
/* ALGORITHM: In any substring that is encountered the most, at least one letter of that substring should be encountered the same time as the substring. So, we just need to find the most encountered symbol in the string. */ using System; using System.Linq; class Program { static void Main() { Console.WriteLine((from u in Console.ReadLine().ToArray() group u by u into gg orderby gg.Count() descending select gg.Key).ToList()[0]); } } Power of Python :) from collections import Counter print(Counter(input().strip()).most_common(1)[0][0]) Power of C/C++ int main() { //shitcode_fiveloops } // AC :) #include <The Power of me!> int main() { ThePowerOfMe.makeItAC(); } ...AC!:) Edited by author 25.04.2014 16:46 I think that one line could be enough. Console.WriteLine(input.GroupBy(c => c).OrderByDescending(g => g.Count()).First().Key); // the power of C++ :) #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main() { string s; cin >> s;
vector<int> v(30, 0); for (int i=0; i<s.size(); ++i) { ++v[s[i]-'a']; } auto c = distance(v.begin(), max_element(v.begin(), v.end())); cout << (char)('a'+c); return 0; } |
Goog morning Programmers | Humoyun[IT of TUIT] | 1723. Книга Сандро | 7 апр 2022 22:01 | 2 |
I think in future I will be a powerfull programmer |
Wrong answer on test 28 | Emanuelco07 | 1723. Книга Сандро | 20 апр 2021 20:08 | 1 |
|
Задание с подвохом? (спойлер) | Desserg | 1723. Книга Сандро | 22 дек 2020 22:55 | 3 |
Бред. В самом деле, достаточно искать символ, который чаще всего встречается.... работает, не мне одному приходят в голову умные мысли... |
abcdefghijklmopqrstuvwxyz | Minos Skistonrak | 1723. Книга Сандро | 1 окт 2018 19:08 | 2 |
What answer in this case? "Output any of the most powerful spells..." Any of them. |
WA 4 | Jonnathan | 1723. Книга Сандро | 6 апр 2017 20:50 | 2 |
WA 4 Jonnathan 25 окт 2012 10:23 My Source import java.util.*; public class JavaApplication3 {
public static void main(String[] args) { String SubPalabra1=""; String SubPalabra2=""; String Correcta="";
String Verdadera=""; int menor; String resto=""; Scanner D=new Scanner(System.in); String palabra=D.nextLine().trim(); if(palabra.length()!=1){ for(int i=0;i<palabra.length();i++){ Verdadera=""; resto=palabra.substring(i+1, palabra.length()); if(resto.indexOf(palabra.charAt(i))!=-1){ SubPalabra1=""+palabra.charAt(i)+resto.substring(0,resto.length()); SubPalabra2=""+resto.substring(resto.indexOf(palabra.charAt(i)),resto.length()); if(SubPalabra1.length()<SubPalabra2.length()){ menor=SubPalabra1.length(); } else{ menor=SubPalabra2.length(); } for(int j=0;j<menor;j++){
if(SubPalabra1.charAt(j)==SubPalabra2.charAt(j)){ Verdadera=Verdadera+SubPalabra1.charAt(j); if(Verdadera.length()>Correcta.length()){ Correcta=Verdadera; } } else{ j=menor; } } }
} } else{ System.out.println(palabra); } System.out.println(Correcta);
} } Who is the word that no work? |
WRONG answer 5 | jakhongir | 1723. Книга Сандро | 12 окт 2016 23:41 | 1 |
#include <bits/stdc++.h> using namespace std; const int N = 112345; int a[N]; int b[N]; main() { string s, t; cin >> s; int cnt = 0; int mx=0; int l=0; int cnte=0; for(int i = s.size() - 1; i >= 0; i --) { t = s[i] + t; a[0] = 0; for(int j = 1; j < t.size(); j ++) { int x = a[j - 1]; while(x > 0 && t[x] != t[j]) x = a[x - 1]; if(t[x] == t[j]) x ++; a[j] = x; mx = max(mx, a[j]); } b[i]=mx; if(mx==0)cnte++; mx=0; } if(cnte==s.size()){cout<<s;return 0;} else for(int i=0;i<s.size();i++){if(b[i]>=1)cout<<s[i];} } // any suggestion guys I have no idea what can be the fifth test thanks in advance |
WA10 | Bogdan Devichev | 1723. Книга Сандро | 7 сен 2016 17:57 | 2 |
WA10 Bogdan Devichev 25 сен 2013 22:52 i dont know but i would like to share something with you. Did u know if the input is : qwertasnuqwertxsqwertplqwert the answer is not "qwert",the answer is "e" !!! |
16 тест | tideee | 1723. Книга Сандро | 19 авг 2016 01:37 | 2 |
помогите, что в нём?!?! спасибо, за помощь ) так. с 16-м разобрался, но что же на 28 ? |
In fact, it's easy to wrap around | zhangweilst | 1723. Книга Сандро | 4 янв 2016 15:29 | 1 |
It is guaranteed that the most often appeared letter is the right answer. Only one letter is needed. |
Troll Problem | Suraj | 1723. Книга Сандро | 26 окт 2015 21:58 | 2 |
This problem is just to troll you. I first thought of doing it using suffix array. Just read the question properly, it says 'any substring'? Didn't you see constraint bro -_- Length is 50 and suffix array :V |
This Problem more looks like a joy! - Careful - telling you why. | BillSu | 1723. Книга Сандро | 25 апр 2014 16:35 | 1 |
One single letter count! Of course, Any substring would include one letter. |
Help! Why do i get Runtime error on test 1? | sialLeo | 1723. Книга Сандро | 14 апр 2014 22:02 | 1 |
Here is my code, what's the problem? #include <algorithm> #include <iostream> #include <vector> #include <sstream> #include <string> #include <cstdlib> #include <cstdio> #include <iomanip> using namespace std; int main(){ int count[26]; int max = 0; char answer = '-'; for (char p = 'a'; p < char('z') + 1; p++) { count[p] = 0; } char c; while (cin.get(c)) { count[c]++; } for (char p = 'a'; p < char('z') + 1; p++) { if (count[p] > max){ max = count[p]; answer = p; } } cout << answer; } |
someone help me to understand the question? | Maral | 1723. Книга Сандро | 3 апр 2014 16:04 | 1 |
it said that the powerful spell is depend on the times it had repeated so in "abababa" "a" is 4 times or "ba" is 3... or in "qqq" whats the answer ?? "q" 3 times or "qqq" 1 time??? |
WA on #16 | Evgeniy_Chernobrovkin(MUCTR-2013) | 1723. Книга Сандро | 22 янв 2014 03:45 | 1 |
WA on #16 Evgeniy_Chernobrovkin(MUCTR-2013) 22 янв 2014 03:45 |
Trolled | ძამაანთ [Tbilisi SU] | 1723. Книга Сандро | 1 авг 2013 20:02 | 1 |
Trolled ძამაანთ [Tbilisi SU] 1 авг 2013 20:02 This topic is devoted to trolled ppl :D God damn it I was ashamed after typing so many string super duper cumbersome functions XD |
WA3 I cant find the error | Arturo | 1723. Книга Сандро | 27 июл 2013 05:49 | 1 |
#include<iostream> #include<stdio.h> #include<string.h> using namespace std; char v[53];int ch[53]; char vi[53][5],*punt=NULL,vf[53],vc[53],vp[53],*a,vt[53],chr[3]; int maxl=0,maxt=0,k,b,max2,l=0; int n,j=0,i,ind; main() { gets(v); n=strlen(v); if(n==1){cout<<v;} else{ for(i=0;i<n-1;i++) { // carga inicial vi[i][0]=v[i] ; vi[i][1]=v[i+1] ; ch[i]=0; } for(i=0;i<n-1;i++) { punt=strstr(v,vi[i]); if(punt!=NULL) { ch[punt-v]++; } } for(i=0;i<n-1;i++) { if(ch[i]>maxt) { maxt=ch[i]; ind=i; } } strcpy(vc,vi[ind]); strcpy(vp,v); punt=strstr(v,vi[ind]); i=0; strcpy(vf,vi[ind]); if (maxt!=0) { while(1) { b=1; punt=strstr(v,vf); chr[0]=punt[2+l]; strcat(vf,chr); k=2+l; k++; l++; if(l==strlen(punt))break; max2=0; strcpy(vp,v); while(1) { punt=strstr(vp,vf); if(punt!=NULL) { j=strlen(punt); for(i=0;i<j-1;i++) { vp[i]=punt[i+1]; } vp[i]='\0'; max2++; if (max2>=maxt) { maxt=max2; strcpy(vc,vf); b=0; } } if(punt==NULL)break; } if(b==3) break; } } cout<<vc; }} |
Help me Why my programm is wrong way? Why test 5? | Adhambek | 1723. Книга Сандро | 18 май 2013 09:29 | 1 |
i can't understand this about problem. who can help me? please. give me some test and with correct answer. I'm waiting for you. |
about abababa | data lapiashvili | 1723. Книга Сандро | 15 фев 2013 13:25 | 5 |
is in your example abababa right answer aba or only a??? because a is 4 and aba is 3. test №1: "abababa" ; correct answer: "a" test №2: "abcde" ; correct answer: "abcde" For "abcde" correct: a, b, c, d, e, ab, bc, cd, de, abc, bcd, cde, abcd, bcde, abcde Edited by author 15.11.2010 10:11 why correct answer is "a" , in my opinion answer must be "ababa" cause prefix is like that 0 0 1 2 3 4 5 |
How can my program get AC even it returns wrong answer for the first test? | JAVATAR | 1723. Книга Сандро | 16 окт 2012 07:38 | 3 |
Hello, How can my program get AC even it returns wrong answer for the first test? import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter;
public class SandrosBook {
public static void main(String args[]) throws IOException{
InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); PrintWriter out=new PrintWriter(System.out);
int[] a=new int[26];
String s=br.readLine(); int i=1; int start=0,end=0; start=s.charAt(0)-97; int max=0;
while(i<s.length()){ char c=s.charAt(i); a[(int)c-97]++; i++; }
int k=0; for(int ii=0;ii<26;ii++){ if(a[ii]>max) { max=a[ii]; k=ii; } }
k=k+97;
System.out.println((char)k); out.flush(); }
} try test: b right answer "b", but you output "a" Edited by author 09.03.2012 14:09 |