| Show all threads Hide all threads Show all messages Hide all messages |
| Solved have a question about unsigned integer arithmetic in C/C++ | Nikita Mogilevets | 1528. Sequence | 28 Jun 2017 13:12 | 1 |
Why if I am trying to precalculate factorials using unsigned long long int there is WA#5? There are 64 last binary digits digits and in this task we are to output at most 32 binary digits. |
| Just to know | gepto | 1059. Expression | 27 Jun 2017 23:08 | 1 |
There are no tests where N=0 xD) |
| who knows test18 please tell me | Stevexx | 1966. Cycling Roads | 27 Jun 2017 12:43 | 1 |
#include<cstdio> #include<cstring> #include<iostream> #define pii pair<int,int> #define pdd pair<double,double> #define mp make_pair #define F first #define S second #define N 210 using namespace std; int n,m; int fat[N]; pii e[N]; pdd p[N]; int father(int x) {if(fat[x]!=x) fat[x]=father(fat[x]); return fat[x];} double calc(pii a,pii b,pii c) {return (a.F-c.F)*(b.S-c.S)-(b.F-c.F)*(a.S-c.S);} bool judge(pii a, pii b, pii c, pii d) { if (max(a.F,b.F)<min(c.F,d.F)||max(a.S,b.S)<min(c.S,d.S)||max(c.F,d.F)<min(a.F,b.F)||max(c.S,d.S)<min(a.S,b.S)) return false; if (calc(c,b,a)*calc(b,d,a)<0||calc(a,d,c)*calc(d,b,c)<0) return false; return true; } int main() { int i,j,x,y; scanf("%d %d",&n,&m); for(i=1;i<=n;i++) fat[i]=i; for(i=1;i<=n;i++) {scanf("%lf %lf",&x,&y); p[i]=mp(x,y);} for(i=1;i<=m;i++) {scanf("%d %d",&x,&y); e[i]=mp(x,y); fat[father(x)]=father(y);} for(i=m+1;i<=m+n;i++) e[i]=mp(i-m,i-m); m+=n; for(i=1;i<=m;i++) for(j=i+1;j<=m;j++) if(judge(p[e[i].F],p[e[i].S],p[e[j].F],p[e[j].S])) fat[father(e[i].F)]=father(e[j].F); int stan=father(1); for(i=1;i<=n;i++) if(father(i)!=stan) puts("YES"); return 0; } |
| RANDOM solution is OK! | Nikita Mogilevets | 1731. Dill | 24 Jun 2017 23:17 | 1 |
Just output n random numbers. After that, output m random numbers. All random numbers are in range [1;1e9]. AC first attempt. |
| Be simple. | Nikita Mogilevets | 1800. Murphy's Law | 24 Jun 2017 16:45 | 1 |
At first I wrote a tricky solution using trigonometry and binary search. And I was unable to pass through test case No. 12. Then I wrote simple two-step solution and got AC. |
| WA 19 | Kekwastaken | 1238. Folding | 24 Jun 2017 15:09 | 2 |
WA 19 Kekwastaken 23 Jun 2017 14:15 Can somebody write input? Re: WA 19 Nikita Mogilevets 24 Jun 2017 15:09 I can't write input. I might suggest you are printing numbers X wrong. Or you are allocating not enough space. Or you are using too deep recursion. |
| I'm angry! | __Andrewy__ | 1861. Graveyard in Deyja | 22 Jun 2017 23:43 | 1 |
I wrote program on C++ and got WA1. I rewrote program on Pascal and got AC. I think my error in input string. How do i read lines? My attempts: 1) int c; n=0; while ((c = getchar()) != EOF) { if(c=='\n') break; s[++n]=c; } m=0; while ((c = getchar()) != EOF) t[++m]=(char)c; 2) void Input() { int c; scanf("%c",&c); n=0; while (c!='\n') { s[++n]=c; scanf("%c",&c); } m=0; while ((c = getchar()) != EOF) t[++m]=(char)c; } Probably <string> will help, but i prefer work with index>=1. Edited by author 22.06.2017 23:44 Edited by author 22.06.2017 23:44 |
| Used DP+BIT | sak3t | 1523. K-inversions | 22 Jun 2017 14:00 | 1 |
Used DP + BIT, AC in 0.078 O(n*k*logn) solution. Don't forget, % 10^9 every step. |
| Give me proof why following approach is wrong | Nikita Mogilevets | 1523. K-inversions | 22 Jun 2017 13:53 | 2 |
My approach wrong approach is such. Read cur number X. Find CNT count of numbers Y (Y>X) already read. Find number of ways to pick K-1 items from set of CNT distinctive items. Add that number to ANSWER. Find modulo. Edited by author 11.05.2017 13:28 Your solution is wrong. See for example 6 3 3 4 5 6 2 1 when you read 2, all the numbers before it are > 2 and hence you'll add to your sum, all the possible pairs in previous 4 numbers. But 3 4 5 6 can't make any pair such that a_i > a_{i+1}. Hence your solution doesn't work. Edited by author 22.06.2017 13:55 |
| Solved it by simulation. | Nikita Mogilevets | 1777. Anindilyakwa | 21 Jun 2017 18:16 | 1 |
After we add new pile Z of stones if there is new pair of piles X and Y such that |X-Y| is minimal that either X=Z or Y=Z. So, just add nee pile and recalculate new pair of piles such that the difference between stones count is minimal in O(n) where n is tje number of piles present now. |
| This is running well on Java | Farruh-WIUT | 1877. Bicycle Codes | 21 Jun 2017 04:44 | 2 |
import java.util.Scanner; /** * Created by macbookpro on 2/19/15. */ public class JavaThieves877 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int c1 = Integer.parseInt(scanner.nextLine()); int c2 = Integer.parseInt(scanner.nextLine()); if(c1 % 2==0 || c2 % 2!=0 ) { System.out.print("Yes"); } else if(c1 % 2 != 0 || c2% 2== 0) { System.out.print("No"); } } } Nevermind I didn't read that this is running well:) Edited by author 21.06.2017 04:49 |
| wa 13 | LastOne | 1716. Alternative Solution | 20 Jun 2017 22:59 | 2 |
wa 13 LastOne 13 Jun 2017 00:51 You can try use these tests: 4999 12832 ->2455.1680336 5000 12345 ->2490.9210000 4987 9999 ->50.7443353 1234 3456 ->394.1183144 2976 6547 ->952.8800403 3487 8000 ->1448.9340407 4955 11111 ->1820.5574168 456 968 ->99.1228070 43 123 ->10.4651163 1 2 ->1 4 9 ->2.2500000 3 9 ->0 2 5 ->1.5 2 4 ->1 4399 13013 ->352.6492385 4321 9923 ->1803.1751909 4001 10500 ->1877.1534616 4000 10001 ->2000.4992500 4000 10000 ->2000.5000000 4123 9999 ->2015.9083192 |
| "Ordinary" minus '-' from ASCII set is OK. | Nikita Mogilevets | 1149. Sinus Dances | 20 Jun 2017 22:50 | 1 |
At first I thought I was getting WA's because of the wrong minus sign. Actual reason was printing integers. I was trying to print integers using just PUTCHAR. Of course it worked fine for 0-9. And was failing for other numbers. |
| I solved it with Python | Nikita Mogilevets | 2002. Test Task | 20 Jun 2017 00:56 | 1 |
I tried to solve it with C++. It was long. It was PAINFUL! Finally, I didn't managed to solve it in C++. And then I just opened my Python IDE and solves it within 10 minutes. Just AC first attempt. The task is evil. |
| Use heap. Use number 0.5*K+1. | Nikita Mogilevets | 1025. Democracy in Danger | 17 Jun 2017 01:05 | 1 |
|
| Right Algo: | bsu.mmf.team | 1222. Chernobyl’ Eagles | 16 Jun 2017 22:11 | 5 |
The product of natural numbers with a given condition in this problem will be maximal if and only if the middle arithmetic of these numbers is the most closely to the number e=2.71828... It's a mathematical sentence which are proved! P.S. Sorry for my bad English Why is that true? You can get AC without math :P Well, you only need to understand that optimal partition can't contain any x >= 4(as 2*(x-2) >= x in this case), it obviously can't contain ones, and it can't contain more than 2 copies of 2, as 2*2*2<3*3. Surpisingly, there is only one way to express any x >= 2 as sum of 3's and not more than two 2's. That's a very nice idea. Let me clarify it for those who had problems understanding bsu.mmf.team's English. First of all, 'middle arithmetic' is an arithmetic mean. The thing is, the product will be maximal if (a_1 + a_2 + ... + a_n) / n ≈ e. Well, it's not hard to figure out that the output of the program should be something like that: 3 * 3 * 3 * ... * ? |
| AC in 0.249 and 8668 KB (RMQ for lca) | sak3t | 1471. Distance in the Tree | 15 Jun 2017 22:06 | 2 |
used RMQ using segment tree to find lca in log(n) total time complexity O(n+q*(lgn)) = O(q*lgn) Almost the same numbers (0.268, 11500) for table for 2^i -th ancestor. |
| Graph problems ratings are really strange. | Nikita Mogilevets | 1291. Gear-wheels | 14 Jun 2017 16:52 | 1 |
Some graph problems having very low rating (caravans, Ivan's car) are quite hard to solve while some other problems (like Gear-wheels, Labyrinth) have rating two times higher and are incredibly easy. |
| My solution works as follows : | Nikita Mogilevets | 1139. City Blocks | 13 Jun 2017 21:25 | 1 |
For each x (x=0,1,2,..,n-1) (x is horizontal axis) find y0=x*tg(a) and y1=(x+1)*tg(a), where tg(a) is (m-1)/(n-1). Add to answer floor (y1) - floor(y0) +1. If y1 is a whole number then subtract 1 from answer. |
| what mistake? | Evgenii | 1991. The battle near the swamp | 13 Jun 2017 18:03 | 2 |
program pr; Var n,k,i,s,q:integer; a:array[1..100000] of integer; b:array[1..100000] of integer; Begin q:=0; read(n,k); for i:=1 to n do readln(a[i]); for i:=1 to n do b[i]:=k-a[i]; for i:=1 to n do begin if b[i]<0 then s:=abs(b[i]); if b[i]>=0 then q:=q+b[i] ; end; write(s,' ',q) End. |