| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| Java 8: How to use both input and output? | Ionkin M [Samara SAU #617] | 1601. АнтиКАПС | 15 июл 2019 19:38 | 2 |
Sorry for my bad English. I use int ch; while ((ch = System.in.read()) != -1) { // my solution System.out.print(<some char>); } System.out.println(); But I get WA #1 with or without last code line. I also used System.out.flush (without last line), but it do not help me. Use Scanner from utils,that's better and esier , than use System.in.read() |
| wa on test 55 | Abid29 | 2111. Платон | 15 июл 2019 00:46 | 2 |
Edited by author 24.06.2019 13:55 use 'long' instead of 'int' as accumulator |
| No subject | ∭Andreyka∭ | 2025. Стенка на стенку | 14 июл 2019 12:16 | 1 |
hEdited by author 19.07.2019 12:15 Edited by author 19.07.2019 12:16 |
| WA test №6 Python | Alex | 1263. Выборы | 14 июл 2019 02:59 | 2 |
import math nm = input().split() n = int(nm[0]) m = int(nm[1]) res = set() result = [] for i in range(m): x = int(input()) if x not in res: res.add(x) result.append(x) answer = [] for i in res: answer.append(result.count(i)) while n - len(answer) > 0: answer.append(0) for i in answer: v = str(round(i*100/m, 2)) if v[-2] + v[-1] == '.0': print(str(round(i*100/m, 2)) + '0%') else: print(str(round(i*100/m, 2)) + '%')
Edited by author 24.02.2019 01:39 Edited by author 09.03.2019 03:19 n, m = [int(x) for x in input().split()] x = 0 k = [0]*(n) for i in range(m): x = int(input()) k[x-1] = k[x-1]+1 for u in range(n): print( "%.2f" % (k[u]*100/ m), "%", sep="" ) |
| WA #9 / WA #11 | 👨🏻💻 Spatarel Dan Constantin | 1188. Library | 12 июл 2019 21:26 | 2 |
input: 10 5 4 4 2 1 1 4 0 4 3 0 10 4 10 output: 1 4 14 6 1 5 4 1 4 3 0 3 3 0 13 4 7 4 7 1 0 1 5 3 1 0 1 output: 1 3 |
| Tle in 6? Look at source code. | Farhad Jabiyev | 1654. Шифровка | 12 июл 2019 20:08 | 4 |
#include <iostream> #include <cstdlib> #include <deque> using namespace std; int main() { int h; char s[200001]; scanf("%s", &s); int n=strlen(s); deque<char> v (s, s + n );
if(v.size()==2 && v[0]==v[1] ) return 0; b: h=2; for(int i=0; i<v.size()-1 ;i++) if(v[i] == v[i+1]) { v.erase(v.begin() + i); v.erase(v.begin() + i); h=1; } if(h==1) goto b;
for(int i=0; i<v.size(); i++) cout << v[i];
return 0; } Hello, If you are still working on this, let you know that it can't be solved with erase. I implemented a similar algorithm in Java which goes through the string and deletes the successful characters and it also got TLE on test 6.The easiest way is removing the successful characters as you read them. nc->new character from the input. if(i!=-1&&c[i]==nc){//new char is equal to the char at the end of the string, remove it i--; }else{ //add the new char to the string i++; c[i]=nc; } Hope this helps You got TLE because deque has poor deletion performance on positions other than the front and back. |
| NP-hard?! | Erop [USU] | 1208. Соревнование легендарных команд | 12 июл 2019 15:09 | 4 |
very similar to the NP-complete problem 3-dimensional matching (3-сочетания) Yes, this problem is NP-hard. i have a not brute force solution. The conditions of the problem impose restrictions on the graph But your algorithm is wrong :) We added more tests and now you have WA. Thank you! |
| Nice sequence | candide | 1079. Максимум | 12 июл 2019 04:18 | 3 |
You can solve the question very fast with appropriate precomputed values. The sequence is known as the Stern-Brocot sequence, I was not aware of it before! |
| No subject | Vladimir Putin | 2018. Дебютный альбом | 12 июл 2019 04:18 | 1 |
Edited by author 12.07.2019 04:29 |
| can u help me? here is my code | beautiful | 1607. Такси | 12 июл 2019 02:19 | 7 |
#include<iostream> using namespace std; int main(){ int petr,a,taxi,b; int temp; while(cin>>petr>>a>>taxi>>b){ if(petr>=taxi)cout<<petr<<endl;
else{ temp=taxi-petr; if(a<=b){ while(temp>b){ petr+=a,taxi-=b; temp=taxi-petr; } cout<<petr+a<<endl; } else{ while(temp>a){ petr+=a,taxi-=b; temp=taxi-petr; } cout<<taxi<<endl; } } } } i pass all the test that the discuss give but i still get wa at #4 could u give me some new test? if(a<=b) ---> if(a<b) but i still get wa at #13 for exanmple try test 1000 2 2000 3 the right answer is 1400 but your prog output 1402 or try this 1 2 12 3 right is 6 but yours is 7 Edited by author 20.03.2008 17:57 thanks for 2nd test, it really helpfull) // solve #include <iostream> using namespace std; int main() { int a,b,c,d; cin>>a>>b>>c>>d; while(a< c) { if(a+b > c) { a=c; break; } a= a+b; if(c <= a) { break; } c = c-d; }
cout<<a<<endl; return 0; } |
| TLE #2 & WA #2 | 👨🏻💻 Spatarel Dan Constantin | 2059. Не общие подпалиндромы | 11 июл 2019 03:01 | 1 |
First and foremost, is seems to me that there are only two test cases: (1) the sample case (2) an 8MB test case For WA this test helped me: input: 2 bbaadbdcc aadbdbcbadb aadbdbcbadb bbaadbdcc output: Case #1: 3 2 5 Case #2: 5 2 3 For TLE: parse the input I optimized all sorts of things but eventually I ran out of ideas. Then I remembered someone else was mentioning he submitted the same code again and passed got rid of TLE. Also, from my own experience, I noticed there was a sort of "randomness" in the time execution from one submission to another. (I was able to detect it by killing my program after processing 6MB of the input file.) At this point I was seriously considering speeding up the input reading part of my program using custom code instead of stdin.h. I got 760ms for processing 6MB of the input and I said to myself I'm really close: my code should run in 1.040s. And so I decided to parse the input: I got AC in 560ms! A 480ms boost of speed! So... long story short: parse the input! |
| Some test, which may help you | Dmytro Dziuma (DixonD) [Lviv NU] | 1203. Научная конференция | 10 июл 2019 16:22 | 2 |
5 1 9 14 15 1 11 12 13 10 15 Right answer is 3, but some algorithmes may give answer 2 for this test. P.S. I had this mistake:( P.P.S. Sorry, for my poor English... Thank you! This test helped me to fix WA6 Edited by author 10.07.2019 16:23 |
| WA14 | Skiminok | 1400. Сотовые символы | 8 июл 2019 19:37 | 2 |
WA14 Skiminok 17 мар 2008 02:01 WA14(( No ideas... I tried any tests my brain could imagine. Can anybody help, plz? Hello, I can help you if want. If you give me your email I write you what I made to got AC from WA14.Sorry for bag english Edited by author 08.07.2019 19:37 |
| Some special test pls | Hemaeg | 1658. Сумма цифр | 8 июл 2019 14:23 | 6 |
I have try many of my tests, but I don't know what is wrong in my code. What is test #2, please? Try this one: INPUT 10 1 1 10 100 200 400 900 8100 45 285 456 2119 456 2120 456 3456 456 4080 456 4081 OUTPUT 1 No solution 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 14667777 No solution 1334444444444444444444444444444444444445555555555555555555555555555555555555555555555555555555555555 2677777777777777777777777788888888888888888888888888888888888 888999999999999999999999999999999999999999999999999 No solution Thank you for your test data! WA2 Ilya 8 июл 2019 14:23 Thks you bruh. ths s1 and s2 hack me ->(456 2120) Me too. I try the Special test but it's wrong #2 test still. The #2 test is 100 100 ,or others which the length is 100. |
| Runtime error , Case 8 | Sarvagya Agarwal | 1012. K-ичные числа. Версия 2 | 6 июл 2019 10:17 | 3 |
Why does this give runtime error #8 . n = int(raw_input()) k = int(raw_input()) dp = [[-1 for x in xrange(15)]for y in xrange(1910)] def solve(index,prev) : if(index > n ) : return 1 if(dp[index][prev] != -1) : return dp[index][prev] res = 0 start = 0 if(index == 1) : start = 1 for i in xrange(start,k) : if(prev == 0 and i == 0) : continue res = res + solve(index+1,i) dp[index][prev] = res ; return res print solve(1,0) Same for me, solution is python3. You have to check for recursion depth exceeded. Do it iterative. |
| тест №6 в чем проблема? pascal | Alectros | 2023. Дональд-почтальон | 5 июл 2019 20:53 | 4 |
var str: string; i,kol,n,pol: integer; begin readln(n); pol:=1; kol:=0; for i:=1 to n do begin readln(str); if (str='Alice')or(str='Ariel')or(str='Aurora')or(str='Phil')or(str='Peter')or(str='Olaf')or(str='Phoebus')or(str='Ralph')or(str='Robin') then begin kol:=kol+abs(pol-1);pol:=1; end else if (str='Bembe')or(str='Belle')or(str='Bolt')or(str='Mulan')or(str='Mowgli')or(str='Mickey')or(str='Silver')or(str='Simba')or(str='Stitch') then begin kol:=kol+abs(pol-2);pol:=2; end else if (str='Dumbo')or(str='Genie')or(str='Jiminy')or(str='Kuzko')or(str='Kida')or(str='Kenai')or(str='Tarzan')or(str='Tiana')or(str='Winnie') then begin kol:=kol+abs(pol-3);pol:=3; end; end; write(kol); end. Edited by author 17.11.2016 23:36 Edited by author 17.11.2016 23:36 For me it was a type mistake in "Mickey" а все моя ошибка написал "Bembe" вместо "Bambi" |
| WA #6 | 👨🏻💻 Spatarel Dan Constantin | 1188. Library | 4 июл 2019 21:42 | 1 |
WA #6 👨🏻💻 Spatarel Dan Constantin 4 июл 2019 21:42 input: 6 5 6 4 2 1 0 6 1 5 3 0 6 0 6 output: 2 6 |
| Bad interpretation | foxlup | 1397. Игра в точки | 4 июл 2019 18:44 | 1 |
Why the second difference is 1.937 and no 2.000? |
| WA #7 | 👨🏻💻 Spatarel Dan Constantin | 1177. Сопоставление с шаблоном | 3 июл 2019 23:00 | 1 |
WA #7 👨🏻💻 Spatarel Dan Constantin 3 июл 2019 23:00 input: 1 'a-z' like 'a-z' output: YES Edited by author 03.07.2019 23:01 Edited by author 03.07.2019 23:01 |
| 6. case | Strahinja Popovic | 1177. Сопоставление с шаблоном | 3 июл 2019 22:50 | 2 |
6. case Strahinja Popovic 12 апр 2010 18:46 Hi, I have tried like million times different combinations, and it always gives wrong answer, always on 6. case. Does anyone have 6. case? Does any anyone have any idea what kind of strings/patterns are in 6. case? Thanks in advance Re: 6. case 👨🏻💻 Spatarel Dan Constantin 3 июл 2019 22:50 In test 6 there are several consecutive '%' chars in the pattern. I got TLE, then replaced "%%" with "%" and passed. I'm guessing you can get WA on test 6 if you're not matching the empty string with "%". |