| Show all threads Hide all threads Show all messages Hide all messages |
| Great Problem! :-) | Ostap Korkuna (Lviv NU) | 1324. Extra Spaces | 18 Jan 2018 07:16 | 5 |
I'd like to thank authors for this problem - it became one of my favorite on Timus! Thanks again for very interesting problem! :-) what is that can you tell me what problem it is It's the one that is in the caption of this message :-) It's 1324. Yeah.. But limits could be higher... What about 10^20? :) Or even 10^33. 64-bit integer is still enough (for answer, not for input, but we can just ignore too long input). Or even 10^{10^4}. Works for naive long multiplication. Or even 10^{10^5}. Works in 0.3 in python (only 8 lines!). Or even 10^{10^6}. Hello, FFT! For problem can be solved in T(n), where n = length of input, T(n) is time of multiplication. |
| Floyd-Steinberg dithering works!!! | B@R5uk | 1363. Halftones | 17 Jan 2018 15:53 | 2 |
Unfortunately entirely deterministic version of this algorithm fails on Test #10. So I'm very curious about this Test #10. Because I've done a lot of testing in MATLAB of varoius modification of Floyd-Steinberg dithering algo, including zig-zag proseccing and edge attending. In all cases constraint in statement can be hardened from 20 to 10 and even less. On normal images error is about 6-8. I guess Test #10 some kind of periodic image, that has bad compatibility with that unnatural restriction put in the problem. I mean it square form and discontinuous nature. I think dithering yield much more better image than that which can be produced by uniform minimization of constrain function. I solve this issue whit Test #10 by adding a little bit of randomness in my dithering algo. I mean in place of this threashold function: int quantize(int value) { if (127 < value) { return 255; } return 0; } I'm using this function: int quantize(int value, int randomness) { if (127 - randomness + rng.nextInt(2 * randomness + 1) < value) { return 255; } return 0; } This provides me with magical parameter "randomness" varying which and playing tambourine I got my AC. 8-] I think I should add constraints checking and reprocessing in case the check was a fail, but I'm too lazy, I guess in case of possible future rejudging everything will be fine. :) I express my sincerest thanks to authors of this beautiful problem. It has bugged me a lot in era of matrix printers how can they do this funny dotted images. Finally I have my answer and I can even do it myself!!! Edited by author 17.01.2018 02:43 There is very good article about others dithering algorithms: http://www.tannerhelland.com/4660/dithering-eleven-algorithms-source-code/ It even mention static dithering. But I want to disagree over the way they implemented error partitioning to distribute it among neighbouring pixels: they are dividing the error, then multiplying it and then adding to neighbours. Using integer arithmetics this leads to relatively big errors producing that can be reduced by first multiplying and only then dividing. But this approach has the same error source, namely discading remainder after division, it's just not multiplied further. Taking into account constrants put in the problem it will be much better to calculate all the remainders and put them in one or more pixels. Just compare the following: { error1 = 1 * (error / 16); error3 = 3 * (error / 16); error5 = 5 * (error / 16); error7 = 7 * (error / 16); } { error1 = (1 * error) / 16; error3 = (3 * error) / 16; error5 = (5 * error) / 16; error7 = (7 * error) / 16; } { error1 = (1 * error) / 16; error -= error1; error3 = (3 * error) / 15; error -= error3; error5 = (5 * error) / 12; error -= error5; error7 = (7 * error) / 7; } Edited by author 17.01.2018 15:59 |
| ответ на С++ | Anastasiya | 1787. Turn for MEGA | 17 Jan 2018 14:42 | 2 |
#include <iostream> using namespace std;
int main() { int k, n, res=0; cin >> k >> n; int *mas = new int[n];
for (int i=0; i!=n; i++) { cin >> mas[i];
if (mas[i] > k) { res = res + (mas[i] - k); } else { if (res!=0 ) { if ((k - mas[i]) > res) { res = 0; } else { res = res - (k - mas[i]); } } }
} cout << res; return 0; } This is the mean. Edited by author 17.01.2018 14:44 |
| How fast can you solve it for the case d <= n? | ARK (***AESC_USU***) | 1827. Indigenous Wars | 16 Jan 2018 07:51 | 1 |
|
| wrong 8 why?? | Nursat Yermakhanbet | 1567. SMS-spam | 16 Jan 2018 06:54 | 1 |
ll n, m, ans; st s; int main(){ while(cin >> s){ for(int i = 0;i < s.sz;++i){ if(s[i] == 'b' || s[i] == 'e' || s[i] == 'h' || s[i] == 'k' || s[i] == 'n' || s[i] == 'q' || s[i] == 't' || s[i] == 'w' || s[i] == 'z' || s[i] ==',') ans+=2; if(s[i] == 'a' || s[i] == 'd' || s[i] == 'g' || s[i] == 'j' || s[i] == 'm' || s[i] == 'p' || s[i] == 's' || s[i] =='v'|| s[i] == 'y' || s[i] == '.') ans+=1; if(s[i] == 'c' || s[i] == 'f' || s[i] == 'i' || s[i] == 'l' || s[i] == 'o' || s[i] == 'r' || s[i] == 'u' || s[i] == 'x'|| s[i] == '!') ans+=3; } ans++; } cout << ans - 1; }
|
| wa test #3 | acmprep | 1211. Collective Guarantee | 16 Jan 2018 02:11 | 5 |
Why did you got wa on test 3 ? I'm having the same problem... :( try this test: 1 16 2 3 4 5 1 2 3 4 5 2 2 2 2 2 2 0 answer, it is clear, NO, but this test helped me when I had WA#3 I had WA#3, too. That test helped me. 1 5 0 0 0 0 0 It's NO, of course! ) Edited by author 16.03.2006 16:39 Edited by author 16.03.2006 16:40 Or maybe it is 1 5 0 3 4 5 3 Answer: NO >>Or maybe it is >> >>1 >>5 >>0 3 4 5 3 >> >>Answer: NO ASK, thank you. If there is a loop in graph that can be entered by branch from nodes earlier in list then loop nodes than some naive algorithms can fail on this test. By the way, why not to add the tag GRAPH THEORY to this problem? It not that deep though. |
| Help me please! | Roa28 | 1785. Lost in Localization | 15 Jan 2018 18:24 | 4 |
Только начал изучать С++. Решаю задачки для новичков. Что не так здесь? #include <iostream> #include <conio.h> using namespace std; int main() { int A; cout << "How many?"; cin >> A; if(A < 1 || A > 2000) { cout << "wrong input!"; }else { if(A <= 4) cout << "few"; else if(A <= 9) cout << "several"; else if(A <= 19) cout << "pack"; else if(A <= 49) cout << "lots"; else if(A <= 99) cout << "horde"; else if(A <= 249) cout << "throng"; else if(A <= 499) cout << "swarm"; else if(A <= 999) cout << "zounds"; else cout << "legion";} return 0; } компилировал на Visual studio 2012 - все работает. почему тут не принимает? don`t write How many it is wrong : and not "||" you should "&&" it is true good luck #include <iostream> using namespace std; int main() { int a; cin >> a; if (a >= 1 and a <= 4){ cout << "few"; if (a >= 5 and a <= 9){ cout << "several"; if (a >= 10 and a <= 19){ cout << "pack"; if (a >= 20 and a <= 49){ cout << "lots"; if (a >= 50 and a <= 99){ cout << "horde"; if (a >= 100 and a <= 249){ cout << "throng"; if (a >= 250 and a <= 499){ cout << " swarm"; if (a >= 500 and a <= 999){ cout << " zounds"; if (a > 1000){ cout << " legion"; } } |
| Please, say. Where I Wrong? (C#) | Serge | 1020. Rope | 15 Jan 2018 05:46 | 1 |
Edited by author 15.01.2018 06:34 |
| Sol with WA 46, 47, 48 | 🎧 Vadim Barinov \Frez_Fstilus/'``' :) | 1509. Domino Recognition | 14 Jan 2018 02:08 | 2 |
WA 46: 2 0 0 0 0.5 Ans: 0 2 WA 47: 2 0 0 0 99 Ans: 1 1 WA 48: 2 0 0 0 1 Ans: 0 2 1 1 > WA 46: > 2 > 0 0 > 0 0.5 > Ans: > 0 2 Your answer is incorrect. There is no dominoes which fit with your input. Maximum related L (for 0-2 domino) is 1/sqrt(2) that is outside of permissible range of [1, 100]. But thank you nonetheless!!! Your hint allowed me to get my AC 8-] |
| WA 12 | Kekwastaken | 1943. Space Rummy | 14 Jan 2018 01:24 | 2 |
WA 12 Kekwastaken 25 Dec 2017 11:54 Re: WA 12 ARK (***AESC_USU***) 14 Jan 2018 01:24 Increasing (maybe except n) sequence. I.e. something like 1 2 5 3 4, 1 2 3 4 5 6, 7 1 2 3 4 5 6. And answer is "YES". Actually, there are only 7 inputs with answer "NO". Edited by author 14.01.2018 01:28 |
| This is soo000ooo funny problem! | B@R5uk | 1704. Demodulation | 13 Jan 2018 21:30 | 1 |
You need to compute two scalar products, each for 0 bit and 1 bit. Then just compare it. That'a ALL!!! If you are afraid of amplitude being negative then abs() each product and compare them after. There is no need to fuss about anything: carriers and constant level orthogonal to each other and noise guaranteed to be small by problem statement. Well, if noise was too big betrayer would never be able to transmit his data. Even if every bit was transmitted with differen amplitude and different constant level this approach still would work. I just do not undestand why this problem is rated soooooo high?! |
| Chess problem...TLE on test #10!! how to make it faster????? | michel mizrahi | 1298. Knight | 13 Jan 2018 01:57 | 9 |
I really stuck with this, I don't know how to make my algorithm faster here is my code: #include <stdio.h> char board[10][10]; char letter[66],num[66]; int n,s=0,ncuad; int pos_f[8]={-1,-2,-2,-1, 1, 2, 2, 1}; int pos_c[8]={-2, 1,-1, 2, 2, 1,-1,-2}; init_board(){ int i,j; for(i=1;i<=n;i++) for(j=1;j<=n;j++) board[i][j]='0'; } search(int i,int f,int c){ int j=0; if(s==1) return 0; if(board[f][c]=='0'){ board[f][c]='1'; switch(f){ case 1: letter[i]='a';break; case 2: letter[i]='b';break; case 3: letter[i]='c';break; case 4: letter[i]='d';break; case 5: letter[i]='e';break; case 6: letter[i]='f';break; case 7: letter[i]='g';break; case 8: letter[i]='h';break; } num[i]=c; if(i==ncuad) s=1; while(j<8 && s==0){ if((f+pos_f[j])>0 && (f+pos_f[j])<=n) if((c+pos_c[j])>0 && (c+pos_c[j])<=n) search(i+1,f+pos_f[j],c+pos_c[j]); j++; } board[f][c]='0'; } } int main(){ int i,j; scanf("%d",&n); ncuad=n*n; init_board(); for(i=1;i<=n;i++) for(j=1;j<=n;j++) search(1,i,j); if(s){ for(i=1;i<=ncuad;i++) printf("%c%d ",letter[i],num[i]); return 0; } else printf("IMPOSSIBLE\n"); return 0; } if someone can help me I would appreciate a lot!! Precalc (-) Dmitry 'Diman_YES' Kovalioff. Retired 12 May 2005 12:22 else begin writeln('a1'); writeln('b3'); writeln('a5'); writeln('b7'); writeln('d8'); writeln('c6'); writeln('b4'); writeln('a2'); writeln('c3'); writeln('b1'); writeln('a3'); writeln('b5'); writeln('a7'); writeln('c8'); writeln('b6'); writeln('a4'); writeln('c5'); writeln('a6'); writeln('b8'); writeln('d7'); writeln('f8'); writeln('e6'); writeln('d4'); writeln('c2'); writeln('e3'); writeln('d1'); writeln('b2'); writeln('c4'); writeln('d6'); writeln('e8'); writeln('g7'); writeln('f5'); writeln('e7'); writeln('g8'); writeln('f6'); writeln('h7'); writeln('g5'); writeln('e4'); writeln('d2'); writeln('f1'); writeln('h2'); writeln('f3'); writeln('e1'); writeln('g2'); writeln('h4'); writeln('g6'); writeln('h8'); writeln('f7'); writeln('h6'); writeln('g4'); writeln('e5'); writeln('d3'); writeln('c1'); writeln('e2'); writeln('g1'); writeln('h3'); writeln('f2'); writeln('h1'); writeln('g3'); writeln('h5'); writeln('f4'); writeln('d5'); writeln('c7'); writeln('a8'); end; thanks! but can I ask you two questions...? first, how many time takes in your computer if you run my code to get the solution for n=8? because my computer is veryy slow and get stuck and number two is it any way to solve it the problem without precalc?? (sorry for my bad english) and thanks again!!! :D:D:D:D:) byee! and good luck! I didn't use precalc. I calculated answer for N using answer for N-1 if it was not 'No Solution' I took first N moves from it. Use the priority array for the chessboard : void init() { int a,b,c; int chessboard[8][8]={0}; int direction[8][2]= { {2,1},{-2,1},{2,-1},{-2,-1}, {1,2},{-1,2},{1,-2},{-1,-2}, }; for(a=0;a<n;a++) { for(b=0;b<n;b++) { int count=0; for(c=0;c<n;c++) { int x1 = a+direction[c][0]; int y1 = b+direction[c][1]; if(x1>=0&&x1<n&&y1>=0&&y1<n) count++; } chessboard[a][b] = count; } } } For example, n = 8 : 2 3 4 4 4 4 3 2 3 4 6 6 6 6 4 3 4 6 8 8 8 8 6 4 4 6 8 8 8 8 6 4 4 6 8 8 8 8 6 4 4 6 8 8 8 8 6 4 3 4 6 6 6 6 4 3 2 3 4 4 4 4 3 2 go to the cell with minimum priority first ! Good luck ! Edited by author 17.02.2009 12:04 Edited by author 17.02.2009 12:04 How can here be >=10 tests if 1<=n<=8? |
| C# Please, Help! Where is wrong? | Serge | 1563. Bayan | 12 Jan 2018 05:28 | 1 |
The answer is correct, but it returns an error. Why? Maybe I did not understand the condition of the task correctly, or can the data be specified for which this code will produce the wrong solution? using System; namespace ConsoleApp30 { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int x = 0; string[] shoplist = new string[n]; for (int i = 0; i <n; i++) { shoplist[i] = Console.ReadLine(); } for (int i = 0; i < shoplist.Length; i++) { for (int j = i + 1; j<shoplist.Length; j++) { if (shoplist[i] == shoplist[j]) { x++; i++; } else { continue; } } } Console.WriteLine(x); //Console.ReadKey(); } } } |
| Runtime error | Unfeeling | 1545. Hieroglyphs | 12 Jan 2018 02:44 | 2 |
using System; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n = Convert.ToInt32(Console.ReadLine()); string [] ch= new string [100]; string c; for (int i=0;i<n;i++) ch[i]=Console.ReadLine(); c=Console.ReadLine(); for (int i=0;i<n;i++) { if (c==ch[i].Substring(0,1)) Console.WriteLine(ch[i]); } Console.ReadKey(); } } } what's the problem??? help me please Use comment for this line (or delete this line) //Console.ReadKey(); |
| Is it possible to mathematically prove that it is necessary to use the Fibonacci numbers | IlushaMax | 1225. Flags | 11 Jan 2018 09:50 | 2 |
I mean not just to see on examples and find a pattern |
| An explanation why the doubled Fibanucci sequence is suitable here | Ivan Avdonin (Vologda ML, MSU) | 1225. Flags | 11 Jan 2018 09:34 | 1 |
Let's define C(k,n) = n!/(k!(n-k)!). Binomial coefficients are widely used in combinatorics. The number of ways you can place something on something is an binomial coefficient. But we can't place the blue stripe on the end of the flag and side by side. It is well-known, that C(0,n) + C(1,n) + ... + C([n/2],[n/2]) = F[n+1] where F[n+1] is (n+1)-th Fibonacci number and [n/2] is integer division [1]. I hope this my small review does not spoil you the solving of the problem. Thank you. [1] https://en.wikipedia.org/wiki/Fibonacci_number (Use in Mathematics) accepted/sended = 13616/35461 Edited by author 11.01.2018 10:21 Edited by author 17.06.2019 01:04 Edited by author 17.06.2019 01:04 |
| Where is my fault?(C answer) | LK Duan | 1001. Reverse Root | 10 Jan 2018 19:19 | 2 |
#include<stdio.h> #include<math.h> #define size 256*1024/sizeof(long long) int main() { int s=0,l; long long int a[size+1]; do{l=scanf("%lld",a[s++]);}while(l!=EOF); for(s=s-2;s>=0;s--) printf("%.4Lf\n", sqrt((double)a[s])); } The input may contain upto 256 * 1024 / 2 numbers ("1 1 1 1 1 ..."). |
| If you have WA2 | PrankMaN | 1400. Cellular Characters | 10 Jan 2018 19:15 | 2 |
|
| thank you. cool task - | kasarino | 2045. Richness of words | 10 Jan 2018 18:47 | 1 |
|
| wh Test 3 | Khamidjon | 1654. Cipher Message | 10 Jan 2018 15:20 | 1 |
// Harry Poter #include <stdio.h> #include <iostream> #include <stdlib.h> #include <string.h> using namespace std; int main() { char line[200001], w2[200001]; cin.getline(line, sizeof(line)); int t = 0, i; for(i = 0; i < strlen(line); i++){ if (line[i] == line[i + 1]) { i++; A: if (line[i + 1] != line[i + 2]) { if (t != 0 && w2[t - 1] == line[i + 1]) {t--; i += 1; goto A;} } } else {w2[t++] = line[i];} } w2[t] = '\0'; printf("%s", w2); } |