| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| test 5 | Roman | 1014. Произведение цифр | 3 июл 2013 22:35 | 1 |
tell me, please, what input in test 5. |
| python-solvable ? | PSV | 1915. Руины титанов: воссоздание былого | 3 июл 2013 21:26 | 1 |
request for any optimizations possible for python solution: not it get TLE #42 import sys #sys.stdin = open("smalltest.txt") #sys.stdin = open("input.txt") top = 0 stack = [0] * 2000020 input = sys.stdin.read().split() operations = int(input[0]) ans = "" for i in xrange(operations) : op = int(input[i+1]) if op > 0 : stack[top] = op top += 1 elif op < 0 : top -= 1 ans += str(stack[top]) + "\n" else : if operations - i > top : l = max( 0, top - operations + i ) cnt = top - l stack[top:top+cnt] = stack[l:top] top += cnt sys.stdout.write( ans ) |
| Can I decrease flow on some pipeline? (-) | Ilya Rasenstein (Lyceum #40) | 1505. Перекачка нефти | 3 июл 2013 21:03 | 2 |
Yes. We can decrease flow on some pipeline( if the flow on some pipeline is greater zero ). And this operation is free!!! =) |
| To Judges - unclear statement | Zura Isakadze [Tbilisi SU] | 1876. Утро сороконожки | 3 июл 2013 19:14 | 1 |
I think the problem is little unclear. It does not mention if the centipede continues putting shoes with the same strategy for right foot, when it is so. Edited by author 03.07.2013 19:21 |
| solved | Roman Samokhin | 1001. Обратный корень | 3 июл 2013 16:28 | 1 |
solved Roman Samokhin 3 июл 2013 16:28 Edited by author 03.07.2013 17:04 |
| it is'nt problem ! | Mattiev Jamol | 1336. Проблема Бен Бецалеля | 2 июл 2013 16:58 | 1 |
you must print n^2 and n. |
| o(1) solution | Arseniy | 1353. Миллиардная Функция Васи | 1 июл 2013 23:30 | 1 |
You can solve it o(1) just precalc answers fir all test by brute forse, than put it to array. Proffit |
| wrong answer #1 | Dejust | 1601. АнтиКАПС | 1 июл 2013 01:30 | 3 |
my code: #include <string> #include <iostream> using namespace std; int main() { string line; getline(cin, line); static bool sing = false; for(int i = 0; i < line.length(); i++) { if(sing) { if((line[i] >= 'A') && (line[i] <= 'Z')) { char temp = line[i] - ('A'-'a'); cout << temp; } else if((line[i] == '.') || (line[i] == '!') || (line[i] == '?')) { cout << line[i]; sing = false; } else if(line[i] == 10 || line[i] == 26) { cout << '\n'; } else { cout << line[i]; } } else { if(line[i] >= 'A' && line[i] <= 'Z') { cout << line[i]; sing = true; } else if(line[i] == 10 || line[i] == 26) { cout << '\n'; } else if((line[i] == '.') || (line[i] == '!') || (line[i] == '?')) { cout << line[i]; } else { cout << line[i]; } } } return 0; } Cause your first char is lower? but it should be upper.. |
| i got AC but somehow i did'n understand this problem.(can you help me?) | cena | 1214. Странная процедура | 1 июл 2013 01:01 | 2 |
hi all; here's a bit simpler algorithm than in the question: if(x > 0 && y > 0) { for(i = 1; i <= x + y; ++i) { y = x * x + y; x = x * x + y; y = sqrt((double)x - y); x -= (2 * y * y); } } could anyone prove it to me how this scary algorithm is the one in O(1), i mean the one that tests reminders and then swap (if necessary). thank you. Edited by author 17.02.2013 15:05 Edited by author 17.02.2013 15:05 Once you've reduced it that far, you can use algebra to show that all the procedure in the for loop really does is swap the variables. That coupled with the conditions of the for loop give you the O(1) solution. Edited by author 01.07.2013 01:03 |
| only using "bfs" | Huang Chen | 1008. Кодирование изображений | 30 июн 2013 14:58 | 1 |
|
| wa4#,some tests ,plz | liyini9 | 1554. Multiplicative Functions | 30 июн 2013 14:52 | 2 |
|
| why does this not work?all inputs give correct output | Niloy | 1493. В одном шаге от счастья | 30 июн 2013 02:57 | 1 |
#include <stdio.h> #include<stdlib.h>
int main() { int arr[5],arr1[5],arr2[5],i,a=0,b=0,n,x=0,y=0; printf("Enter number"); scanf("%d",&n); x=n+1; y=n-1; while(n>0) { for(i=5;i>=0;i--) { arr[i]=n%10; n=n/10; } } a=( arr[0]+arr[1]+arr[2]); b=(arr[3]+arr[4]+arr[5]); // printf("%d%d",a,b); if((a-b==1)||(a-b==-1)) { while(x>0) { for(i=5;i>=0;i--) { arr1[i]=x%10; x=x/10; } } while(y>0) { for(i=5;i>=0;i--) { arr2[i]=y%10; y=y/10; } } if ((arr1[0]+arr1[1]+arr1[2]==arr1[3]+arr1[4]+arr1[5])||(arr2[0]+arr2[1]+arr2[2]==arr2[3]+arr2[4]+arr2[5])) { printf("\nYes");} else { printf("\nNo");} } else { printf("No"); } return 0; } |
| No subject | Niloy | 1820. Уральские бифштексы | 30 июн 2013 01:08 | 1 |
i am doing (n%k)+(n/k) after putting restriction on k(k<=1000) and n(n>=1). but my answer is said to be wrong.please help. |
| No subject | Khalkechev Roman | 1001. Обратный корень | 28 июн 2013 13:55 | 1 |
Edited by author 28.06.2013 19:30 Edited by author 28.06.2013 19:30 |
| Pomogite TLE na 10 teste ; Help TLE on 10 th test | Hamdam_TUIT | 1021. Таинство суммы | 28 июн 2013 10:37 | 1 |
#include<iostream> using namespace std; short a[50001],b[50001]; int N,M,index_1_0,index_1_10,index_2_0,index_2_10; bool f_0,f_10,t_0,t_10; const int T=10000; int main() { cin>>N; for(int i=0;i<N;i++) { cin>>a[i]; if(a[i]>=0&&!f_0) { index_1_0=i; f_0=true; } if(a[i]>=1000&&!f_10) { index_1_10=i; f_10=true; } } cin>>M; for(int i=0;i<M;i++) { cin>>b[i]; if(b[i]<=0&&!t_0) { index_2_0=i; t_0=true; } if(b[i]<=1000&&!t_10) { index_2_10=i; f_10=true; } } for(int i=0;i<=index_1_0;i++) { for(int j=0;j<=index_2_10;j++) { if(a[i]+b[j]<1000) break; if(a[i]+b[j]==T) { cout<<"YES"; return 0; } } } for(int i=index_1_0;i<=index_1_10;i++) { for(int j=index_2_10;j<=index_2_0;j++) { if(a[i]+b[j]<1000) break; if(a[i]+b[j]==T) { cout<<"YES"; return 0; } } } for(int i=index_1_10;i<N;i++) { for(int j=index_2_0;j<M;j++) { if(a[i]+b[j]<1000) break; if(a[i]+b[j]==T) { cout<<"YES"; return 0; } } } cout<<"NO"; } Edited by author 28.06.2013 11:46 |
| WA at test case 4 | sanjeevp | 1954. Пять палиндромов | 28 июн 2013 07:35 | 1 |
Hi, Can someone please help with the type of test case 4. Thanks. |
| i++ and ++i | Neznakomec | | 28 июн 2013 03:52 | 3 |
Sorry, can anyone explain difference between using i++ or ++i in loop for(int i=1;i<=n;++i) or for(int i=1;i<=n;i++) i tried print "i" in loop, all the same int i = 5; int a = i++; int b = i; i = 5; int c = ++i; int d = i; cout << a << " " << b << endl; cout << c << " " << d << endl; The difference comes in when you use it like this: while ( i++ < n ) vs. while ( ++i < n ) also: value = array[ i++ ] vs. value = array[ ++i ]. There is a difference in the for loop version though, more subtle, when you're using iterators/objects instead of plain ints, in short, i++ is more efficient. Except for this efficiency corner case, when "++i" or "i++" is used all by itself, you're correct, there's no apparent difference. Edited by author 28.06.2013 03:54 |
| char array solution,i got 90 for 2 10,still wa #1 | Yinthewind | 1012. K-ичные числа. Версия 2 | 27 июн 2013 23:38 | 2 |
#include<stdio.h> #include<stdio.h> void plus(char *a,char *b,char *c) { char *p1,*p2,*p3; p1=a+99; p2=b+99; p3=c+99; while(*p1!=0||*p2!=0) { *p3+=*p1+*p2-2*'0'; if(*p3>'9') { *p3-=10; *(p3-1)+=1; } p1--; p2--; p3--; } } void multi(unsigned char *s,int k) { unsigned char *p; p=s+99; while(*p!='0') { *p+=(*p-'0')*(k-1); p--; } p=s+99; while(*p!='0') { while(*p>'9') { *p-=10; *(p-1)+=1; } p--; } } void main() { unsigned char a[101],b[101],c[101],d[101]; int n,k,i,j; for(i=0;i<100;i++) { a[i]=b[i]=c[i]=d[i]='0'; } scanf("%d %d",&n,&k); k-=1; a[100]='\0'; b[100]='\0'; c[100]='\0'; a[99]=k+'0'; b[99]=(k+k*k)%10+'0'; b[98]=(k+k*k)/10+'0'; for(i=1;i<n-1;i++) { strcpy(c,d); plus(a,b,c); multi(c,k); strcpy(a,b); strcpy(b,c); } i=0; while(*(b+i)=='0') { i++; } printf("%s",b+i); } no matter right or wrong, bad code |
| ATTENTION | [TDUweAI] daminus | 1446. Волшебная шляпа | 27 июн 2013 22:32 | 1 |
ATTENTION [TDUweAI] daminus 27 июн 2013 22:32 If your code on pascal, don't use "CASE x oF" it's got CE(Compilation error) |
| Wording is unclear | candide | 1017. Лестницы | 27 июн 2013 16:05 | 1 |
Consider for instance the first drawing : in my perception, the staircase has 4 steps because there are 4 horizontal levels. So the first step (ie the lower one) is made up with 4 blocks, the second with 3 blocks, the third one with 2 blocks and the fourth with 2 blocks again ; so the sizes of the steps are not in _strictly_ descending order (the sizes are 4 3 2 2). So what does "size of a step" really mean? the number of blocks between two consecutive horizontal levels ? the height from the ground of a given level? the height between two consécutive levels? "descending order" : how do you count the steps? from right to left? from top to bottom? The task is no more than finding the number of partitions of n into at least two distinct parts. Edited by author 29.06.2013 04:27 |