Show all threads Hide all threads Show all messages Hide all messages |
it is'nt problem ! | Mattiev Jamol | 1336. Problem of Ben Betsalel | 2 Jul 2013 16:58 | 1 |
you must print n^2 and n. |
o(1) solution | Arseniy | 1353. Milliard Vasya's Function | 1 Jul 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. AntiCAPS | 1 Jul 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. Strange Procedure | 1 Jul 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. Image Encoding | 30 Jun 2013 14:58 | 1 |
|
wa4#,some tests ,plz | liyini9 | 1554. Multiplicative Functions | 30 Jun 2013 14:52 | 2 |
|
why does this not work?all inputs give correct output | Niloy | 1493. One Step from Happiness | 30 Jun 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. Ural Steaks | 30 Jun 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. Reverse Root | 28 Jun 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. Sacrament of the Sum | 28 Jun 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. Five Palindromes | 28 Jun 2013 07:35 | 1 |
Hi, Can someone please help with the type of test case 4. Thanks. |
i++ and ++i | Neznakomec | | 28 Jun 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-based Numbers. Version 2 | 27 Jun 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. Sorting Hat | 27 Jun 2013 22:32 | 1 |
ATTENTION [TDUweAI] daminus 27 Jun 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. Staircases | 27 Jun 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 |
It's Impossible | [TDUweAI] daminus | 1510. Order | 27 Jun 2013 13:45 | 1 |
here is my code. In my computer he got AC on test#1. But in timus that got WA#1 var a:array[0..500010] of longint; procedure sort(l,r:longint); var i,j,p,x:longint; begin randomize; i:=l; j:=r; x:=a[random(r-l+1)+l]; repeat while x>a[i] do inc(i); while x<a[j] do dec(j); if i<=j then begin p:=a[i];a[i]:=a[j];a[j]:=p; inc(i); dec(j); end; until i>j; if i<r then sort(i,r); if l<j then sort(l,j); end; var p,j,k,n,i,temp,have:longint; begin readln(n); for i:=1 to n do readln(a[i]); sort(1,n); temp:=-1; for i:=1 to n do begin if a[i]=temp then begin inc(have); continue; end; if n mod 2=1 then k:=1 else k:=0; if have>=n div 2+k then begin writeln(temp); halt; end; have:=1;temp:=a[i]; end; if n=1 then writeln(temp); end. |
Problem Statement Explained | KNIGHT0X300 | 1252. Sorting the Tombstones | 27 Jun 2013 10:41 | 1 |
Transposing means swapping two tombstones NOT reversing the order of all the stones between selected two. |
easy!!! | [TDUweAI] daminus | 1731. Dill | 27 Jun 2013 01:06 | 1 |
easy!!! [TDUweAI] daminus 27 Jun 2013 01:06 1...n print(i) (n+1)...n+m print(i*n) |
Can someone help me with test 8? | DKarev | 1119. Metro | 26 Jun 2013 22:30 | 1 |
I have WA on test 8. Can someone help. I tried every given test in the site but I can't find any mistakes. This is my code: // #include<iostream> #include<cmath> #include<algorithm> #include<iomanip> using namespace std; bool b[2005][2005]; long double a[2005][2005]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); long double diag=sqrt(2)*100; int n,m,k,k1,r; cin>>n>>m>>r; for(int i=0;i<r;i++) { cin>>k>>k1; b[k][k1]=1; } n++; m++; for(int i=2;i<=n;i++)a[1][i]=a[1][i-1]+100; for(int i=2;i<=n;i++) { for(int j=1;j<=m;j++) { a[i][j]=a[i-1][j]+100; if(j!=1 && a[i][j]>a[i][j-1]+100)a[i][j]=a[i][j-1]+100; if(b[i-1][j-1] && a[i][j]>a[i-1][j-1]+diag+0.001)a[i][j]=a[i-1][j-1]+diag; } } cout<<fixed<<setprecision(0)<<a[n][m]<<"\n"; return 0; } |
WA #3 | TheDreamCatcher | 1161. Stripies | 26 Jun 2013 22:02 | 2 |
WA #3 TheDreamCatcher 14 Aug 2011 13:17 If you got WA #3, check case n=1 ;) Re: WA #3 [TDUweAI] daminus 26 Jun 2013 22:02 |