| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| No subject | Jorres | 1019. Перекрашивание прямой | 11 ноя 2017 22:51 | 1 |
Edited by author 11.11.2017 22:53 |
| No subject | Jorres | 1019. Перекрашивание прямой | 11 ноя 2017 22:51 | 1 |
Edited by author 11.11.2017 22:53 |
| I was trying to it in an clever way | Mahilewets | 1002. Телефонные номера | 11 ноя 2017 22:14 | 6 |
I was trying to write TRIE for mnemonic words and DFS that tree with phone number. And I have failed. After that, I wrote just 2-D dimensional dynamic programming solution. DP[i] [j] is minimal number of words to memorize substring [i;j]. And I got success. Used Python. Just input, not stdin from sys. i think you only need 1 array instead of dp[i,j] So probably there is jury solution available on the internet So I have examined jury solution Looks too simple Can't believe it is able to solve the problem where do you find the jury solution? |
| Решение C# | Solution C# | Viktor | 1068. Сумма | 11 ноя 2017 20:18 | 3 |
using System; namespace t1068{ class Program{ public static void Main(string[] args){ int n = int.Parse(Console.ReadLine()); int i = 0; while (n != 1){ if (n >= 1){ i+= n; n--; } else if (n <= 0){ i+= n; n++; } } Console.Write(i + 1); //Console.ReadKey(); } } } using System; class Puzzle { public static void Main() { var n = int.Parse(Console.In.ReadLine()); (int start, int end) = n > 1 ? (1, n) : (n, 1); int sum = 0; for (int i = start; i <= end; i++) sum += i; Console.WriteLine(sum); } } static int Proccess(int input) { if (input == 1) { return 2; } else if (input == 0) { return 1; } bool isInputNegative = false; if (input < 0) { input = input * -1; isInputNegative = true; } int sum = 0; for (int i = 1; i < input + 1; i++) { sum += i; } if (isInputNegative) { sum = sum * -1; sum++; } return sum; } more understandable :D Edited by author 11.11.2017 20:22 |
| I got AC | [NU GYM] I am get tester... | 1414. Астрономическая база данных | 11 ноя 2017 19:12 | 4 |
I got AC [NU GYM] I am get tester... 30 окт 2005 14:51 time 0.078 memory 3 350 kb. I use triplex tree. It is very interesting problem. I used plain arrays and got AC in 0.093 and 410 KB. Solution with std::set and hand-written memory allocator gets AC in 0.062 and 534 KB. Re: I got AC Andrew Hoffmann aka SKYDOS [Vladimir SU] 27 июл 2010 21:37 Where I can find info about triplex tree? I used google, but nothing found... time 0.078 memory 3 350 kb. I use triplex tree. It is very interesting problem. |
| why am i getting WA in test 12 | Grandmaster | 1249. Древний некрополь | 11 ноя 2017 01:59 | 1 |
#include <stdio.h> #include <iostream> using namespace std; int n, m, segRez[3004]; int segm1[3004]; char segm2[6005]; int main() { cin >> n >> m; for(int i = 0; i < n; ++i){ gets_s(segm2); for(int j = 0; j < m; ++j){ segRez[j] = segm1[j] + int(segm2[j<<1] - 48); segm1[j] = int(segm2[j<<1] - 48); if(j - 1 >= 0 && ((segRez[j - 1]|segRez[j])) == 3){ cout << "No"; return 0; } } } cout << "Yes"; } |
| Java or C++ problem !?!?!? | Valiok | 1110. Степень | 9 ноя 2017 19:46 | 2 |
Here is my java code : import java.util.Scanner; public class Example{ public static void main(String []args){ Scanner in = new Scanner(System.in); int number1,number2,number3; int [] array; int position=0; boolean check=false; int sth; number1=in.nextInt(); number2=in.nextInt(); number3=in.nextInt(); array = new int[number2]; for(int i=0;i<=number2-1;i++){ sth=(int)Math.pow(i,number1); if((sth-number3)%number2==0){ array[position]=i; position++; check=true; }else if(i==number2-1 && check==false){ System.out.println(-1); System.exit(0); }
} for(int p=0;p<position-1;p++){ for(int j=p+1;j<position;j++){ if(array[p]>array[j]){ int t=array[p]; array[p]=array[j]; array[j]=t; } } } for(int i=0;i<position;i++){ System.out.print(array[i] + " "); } System.out.println(); } } I get an error on test#3 . And on my C++ solution i get an error on test#6. #include<iostream> #include<cmath> using namespace std; int main(void){ unsigned short int N,M,Y; cin>>N>>M>>Y; unsigned short int X[M]; unsigned short int position=0; bool some_check=false; int sth; for(int i=0;i<=M-1;i++){ sth=pow(i,N); if((sth-Y)%M==0){ X[position]=i; position++; some_check=true; } else if(i==M-1 && some_check==false){ cout<<-1<<endl; return 0; } } for(unsigned short int i=0;i<position-1;i++){ for(unsigned short int j=i+1;j<position;j++){ if(X[i]>X[j]){ swap(X[i],X[j]); } } } for(unsigned short int i=0;i<position;i++){ cout<<X[i]<<" "; } cout<<endl; return 0; } Please,any ideas ??? |
| Shortest solution | Dranik | 1423. Басня о строке | 9 ноя 2017 08:42 | 3 |
int main() { int n; string s1, s2; cin >> n >> s1 >> s2; s1 += s1; int pos = (int) s1.find(s2); switch ( pos ) { case -1: cout << -1; break; case 0: cout << 0; break; default: cout << n-pos; } return 0; } Unfortunately, your solution has been rejudged. :) string.find() is too slow. Good luck! |
| Test 6 | Ramshellcinox | 1002. Телефонные номера | 8 ноя 2017 04:05 | 2 |
Test 6 Ramshellcinox 2 июн 2015 07:49 ¿Any idea of why a code can pass all the tests except the test 6 ? I prove my code with this imput, and it works fine 7325189087 5 it your reality real our 4294967296 5 it your reality real our 213456 12 id a h lm aid aidhlm hl m dhlm ai aid hlm 2017697240238123468420176972402381234684201769724023812346842017697240238123468420176972402381234684 7 azipmwpbgqadtjafhmth azipmwpbgqadtjafhmth azipmwpbgqadtjafhmth azipmwpbgqadtjafhmth azipmwpbgqadtja azipmwpbgqadtjafhmthazipmwpbgqadtjafhmthazipmwpbgqadtjafhmthazipmwpbgqadtjafhmth fhmth 27386428376 0 97854668689678768 3 dfgdfhjghjdggzash dfgkjt nkhhdfsge 11111111111 5 ij jj ji j i 1234567890 5 bdh txo bdhkmp i kmp -1 the answer is : reality our No solution. aidhlm azipmwpbgqadtjafhmth azipmwpbgqadtjafhmthazipmwpbgqadtjafhmthazipmwpbgqadtjafhmthazipmwpbgqadtjafhmth No solution. No solution. ji ji ji ji ji i i bdhkmp txo |
| When its n=4 and k=10 its STACK OVERFLOW!!!! HELP !!! | Kevin Narang | 1009. K-ичные числа | 7 ноя 2017 20:18 | 1 |
This is my code: import time import sys sys.setrecursionlimit(100000) n = int(input("Enter N (for digits): ")) k = int(input("Enter K: ")) rangeVar = pow(k, n) - pow(k, n-1) starter = pow(k, n) - rangeVar counter = 0 start = time.clock() def calc(i): global starter, rangeVar, counter, n, k temp = str(i)
if i == pow(k, n): return counter else: for j in range(len(temp) - 1): if temp[j] == '0' and temp[j+1] == '0': counter += 1 calc(i+1)
calc(starter) end = time.clock() print(rangeVar - counter) print(end - start) |
| small hint | md | 1346. Интервалы монотонности | 4 ноя 2017 16:54 | 3 |
Remove repetitions before applying your algo i.e.: sequences like 2 1 2 2 2 2 1 change into 2 1 2 1 It helped me with WA#21 Yep. For understanding why, lets consider: 1 7 3 2 1 4 4 5 They should be 7 numbers in the list! |
| WA#7 | Loky_Yuri [USTU] | 1280. Topological Sorting | 3 ноя 2017 23:23 | 7 |
WA#7 Loky_Yuri [USTU] 20 дек 2006 19:51 This test is something like this 2 2 1 2 1 2 1 2 Correct answer is YES Thank. This test help me to get AC Re: WA#7 Mihran Hovsepyan {1 kurs of <RAU>} 5 июн 2008 01:40 Thank you very much,but now I've WA#33. Re: WA#7 AYUBXON UBAYDULLAYEV TUIT 20 апр 2013 12:10 Thanks for test, i got AC Re: WA#7 kaa..........ai 28 июн 2013 14:44 Thanks a loooooooooooooooot! |
| Give me Test 4 Please!! | ramil_xp Хуснутдинов Рамиль | 1033. Лабиринт | 3 ноя 2017 22:50 | 23 |
33 .#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#. ................................# #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.# ##.#.#.#.#.#.#.#.#.#.#.#.#.#.#... ...............................## #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.# #..#.#.#.#.#.#.#.#.#.#.#.#.#.#... ................................# #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.# ##.#.#.#.#.#.#.#.#.#.#.#.#.#.#... ...............................## #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.# #..#.#.#.#.#.#.#.#.#.#.#.#.#.#... ................................# #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.# ##.#.#.#.#.#.#.#.#.#.#.#.#.#.###. ................................# #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.# #..#.#.#.#.#.#.#.#.#.#.#.#.#.#.#. ................................# #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.# ##.#.#.#.#.#.#.#.#.#.#.#.#.#.#... ...............................## #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.# #..#.#.#.#.#.#.#.#.#.#.#.#.#.#... ...............................## #.##.#.#.#.#.#.#.#.#.#.#.#.#.#... ................................# #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.# #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.# ##.#.#.#.#.#.#.#.#.#.#.#.#.#.#... ...............................## #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.... answer: 12384 check other tests at timustests.lx.ro 15: #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.# 16: ##.#.#.#.#.#.#.#.#.#.#.#.#.#.###. 第15,16行之间不能连通! I am get WA on test 4 too! test 4 is wrong! 我知道TEST 4怎么WA的了! 有几点要归纳出来: 1: ural 有保留字: Following words are reserved. For Pascal: as class dispose except exit exports false finalization finally initialization is library new on property raise true try 我就使用了"try"这个保留字,结果就编译错误了。 2: 第四个数据的底15,16行不能连通! 所以:要从点(1,1)与点(N,N)分别搜索!(我是广搜) 如果只从点(1,1)开始搜,结果为:5760。 如果只从点(N,N)开始搜,结果为:6624。 两者之和正好是正确答案:12384 ! 希望我写的这些对你有用! IMS:WITHOUT WAX CS,HN,CHINA 2006,07,02 23:55
Thank you very much!You are so clever! thanks a lot!!!!!!!!!!!!!!!! :) you are so clever ! Thanks very much ! 上面的几位聪明的中国大牛同胞,看没看见下面的Rules?明确写着“Messages should be written in English.(消息必须用英文写)”,请遵守规则,谢谢。 ------- To my clever Chinese friends above, didb't you see the Rules below? It says clearly that "Messages should be written in English." Please obey that. Thanks. Hah, i guessed myself that labyrinth can have no way from entrance to exit ) the thing is, there doesn't have to be a path from 1,1 to n,n, so you have to check both sides. i got WA at test 4 ,too! thank you!! why cant't discussion be written in chinese or russia?? # Messages should NOT contain source code (especially correct solutions). why?? i think source code indeed may cause cheat,but someone who always gets WA really need them to improve Edited by author 28.03.2008 06:14 Edited by author 28.03.2008 06:15 Good Point~ Thankx The reanson why Test#4 is valid is we can enter upper left as well as lower right. the thing is, there doesn't have to be a path from 1,1 to n,n, so you have to check both sides. Edited by author 13.08.2009 08:22Simple test for those who had WA #4: 3 ..# .#. #.. Answer is 108. Thanks! I got WA in test 4 too. |
| What is the wa3 and wa6 like? | Wei Zhang | 1029. Министерство | 3 ноя 2017 01:04 | 1 |
Need help. Stuck for serval weeks! What is wa3 like? What is wa6 like? |
| Segment tree. | Mahilewets | 1613. Для любителей статистики | 3 ноя 2017 00:42 | 5 |
Store a sorted array [L...R] in each vertex of your ST, corresponding to [L;R]. Hey! Do you mind explaining the Segment tree approach a little bit more? I still couldn't understand Hi It is frequently called merge sort tree So there is an array TRANSPORTED[i] If we have want to find some value in interval of array cells from i=l to i=r We can do binary search in sorted sequence TRANSPORTED[l], TRANSPORTED[l+1],... TRANSPORTED [r-1], TRANSPORTED[r] In merge sort tree We have some sorted subsequences precalculated It is possible to represent any subsequence [l..r] as union of O(log(n)) such precalculated subsequences |
| А как создать свой тутрнир? | Anna | | 2 ноя 2017 20:54 | 1 |
Скажите, пожалуйста, как можно на Вашем сайте создать свою "олимпиаду", турнир по программированию. |
| WA #8 | Amil Khare | 1135. Новобранцы | 2 ноя 2017 08:06 | 2 |
WA #8 Amil Khare 2 ноя 2017 06:30 Please Help and give me some tests! Never mind got it. The case is like this 10 <<<<><>>>> I just forgot to count the '>' that can never be used for swapping. |
| No subject | Hopelessness | 1563. Баяны | 1 ноя 2017 20:44 | 1 |
Edited by author 01.11.2017 20:58 |
| About WA1 | Pavel Kurochkin | 1102. Странный диалог | 1 ноя 2017 18:21 | 1 |
If in the line "outputon", this does not mean that you need to put "out" and "puton", since sometimes you can put "output" and "one". Сheck out this test: 1 outputone Answer : "YES" Perhaps this will help you. Edited by author 01.11.2017 18:28 Edited by author 01.11.2017 18:29 |
| Problem | jackkiu158 | 1045. Забавная игра | 1 ноя 2017 13:23 | 1 |
Problem jackkiu158 1 ноя 2017 13:23 If start from all the leaf airport that from one airport could win, start from this airport suerly will lose. Otherwise,he could win. |