| Show all threads Hide all threads Show all messages Hide all messages |
| This is a cool problem | Rabbit Girl ♥ | 1320. Graph Decomposition | 18 May 2019 19:02 | 2 |
So, we can decompose like this any connected graph G = (V, E), |E| = 2k, k in Z+? This is lovely, this is nice (I proved it using induction, I'm proud of myself, yay!). I came up to this idea, but failed to proof. |
| Accepted simple approach for this problem | Gleb Dubosarskii | 1467. Sum of Degrees | 17 May 2019 19:39 | 2 |
It is easy to solve this problem by using such recursive formula (k+1)P_k(N)=(N+1)^(k+1)-1-sum_(l=0)^(k-1) C_(k+1)^l P_l(N), where P_k(N) is a sum of powers k from 1 up to N, C_k^l is a binomial coefficient. I assume that P_0(N)=N. You can check this formula by summing up from 1 to N following identities (n+1)^k-n^k=sum_(l=0)^(k-1) C_k^l n^l. However, P_k(x) has non-integer coefficients, so it is better to introduce polynomials Q_k(x) by formula Q_k(x)=(k+1)!P_k(x). It can be proven by induction based on recursive formula above that Q(x) has integer coefficients!!! So, use BigIntegers in Java, otherwise you would have overflow. Good luck! Edited by author 08.05.2017 19:44 Edited by author 08.05.2017 19:44 You can make a system of linear equations with k+2 variables and equations, which would look like: A_0 * 1^0 + A_1 * 1^1 + ... + A_(k+2) * 1^(k+2) = 1^k A_0 * 2^0 + A_1 * 2^1 + ... + A_(k+2) * 2^(k+2) = 2^k ... A_0 * (k+2)^0 + A_1 * (k+2)^1 + ... + A_(k+2) * (k+2)^(k+2) = (k+2)^k So, you only need to find A_i coefficients using Gaussion elimination. |
| Hint | xyqxyq | 1052. Rabbit Hunt | 17 May 2019 14:41 | 1 |
Hint xyqxyq 17 May 2019 14:41 n^3 is suitable for which n<=200 but pay attention to the collinear problem Edited by author 17.05.2019 14:43 |
| To admins | basuki | 1590. Bacon’s Cipher | 17 May 2019 00:16 | 1 |
|
| Who knows test 18? | Anna | 1966. Cycling Roads | 16 May 2019 16:47 | 1 |
|
| interesting solution - it works!!)) | Eternal | 1044. Lucky Tickets. Easy! | 16 May 2019 12:08 | 16 |
#include <stdio.h> int main(){ int n; scanf("%d", &n); if (n == 2) { printf("10"); return 0; } if (n == 4) { printf("670"); return 0; } if (n == 6) { printf("55252"); return 0; } printf("4816030"); return 0; } Here is nothing interesting! It's cheating solution. You precalc all variants and nothing else. I don't think, that this solution is cheating, but it also isn't interesting. Just a simple problem.) It is easy to understand why it works but how did you calculate the numbers for 4, 6, 8? With a calculator?!! In Russian this solution call "Частный случай" "Частный случай" you are right! Every one has a chance to say some thing in mother language...i also saying... এতে ইজি কিছহু নাই। সব ই কথিন। oho~I found a partner, Chinese man বুকে আসেন ভাই :D @shahed adnan Edited by author 04.05.2019 21:05 Edited by author 04.05.2019 21:05 This code works but that's not real ans. Edited by author 16.05.2019 12:10 Well he wrote a programm to calculate the answers first, so this is a solution. And due to the performace it is the very good solution. So stop winning and be smart guy. Thanks for giving test data!! \*^_^*/ |
| Another solutions? | scidylanpno | 2114. My craft | 15 May 2019 22:38 | 2 |
I thought my solution is quite "brute", are there any other solutions? And I have to say it is a really good problem for sufficient samples and a clear statement. And where is your solution? |
| Am I stupid? | Alexander Sokolov [MAI] | 1487. Chinese Football | 14 May 2019 23:24 | 11 |
I cant ivent any tests that my solution will fail, but I have WA1! Can any body help... Give me some test! Plz... example tests 4 0110 0011 0001 1000 4 1 4 2 3 3 2 4 1 my output: No No No No 3 010 000 100 3 1 3 3 1 2 3 out: No Yes No Is it correct? Give some more tests! You should print "YES", but not "Yes"... WA 2 CODE: program china; var t:char; i,j,k:integer; a:array[1..100,1..100] of boolean; b:array[1..100] of integer; chk:array[1..100] of boolean; x,y,q,n,m:integer; procedure solve(k:integer); var i:integer; begin for i:=1 to n do begin if a[k,i] then begin if not chk[i] then begin chk[i]:=true; solve(i); end; end; end; end; begin readln(n); for i:=1 to n do begin for j:=1 to n do begin read(t); if t='0' then a[i,j]:=false else a[i,j]:=true; end; readln; end; for i:=1 to n do begin fillchar(chk,n,false); solve(i); for j:=1 to n do begin if chk[j] then b[i]:=b[i]+1; end; end; readln(q); for i:=1 to q do begin readln(x,y); if b[x]>b[y] then writeln('YES') else writeln('No'); end; end. may be this test will help you: 4 0010 0001 0100 0000 4 1 2 1 4 4 1 4 3 answer: YES YES YES No Why answer for 1 4 and 4 1 YES and what is the anwer for 4 0100 0000 0001 0000 7 1 2 2 1 3 4 4 3 3 1 1 3 3 2 Why answer for 1 4 and 4 1 YES Because you should print "No" only if nodex x and y have common predecessor. In other cases you should print "YES". My answer for your test: YES YES YES YES YES YES YES Thank you, your answer helped me mutch! Because you should print "No" only if nodex x and y have common predecessor. In other cases you should print "YES". Where this is written in the statement? Why can't I solve the problem this way: 1. Make transitive closure of the given graph (matrix A)using Floyd. 2. For every request (pair i j) print "YES" if A[i][j] = 1 otherwise print "No". Because you should print "No" only if nodex x and y have common predecessor. In other cases you should print "YES". Where this is written in the statement? Here: "In this case we say that the team A is stronger than the teams B and C (more formally, A is stronger than B if A has beaten B or if A has beaten a team C which is stronger than B)." Edited by author 18.10.2006 23:11 Edited by author 18.10.2006 23:114 1 anwer is No, because 1 better than 3, 3 better than 2, 2 better than 4 => 1 better than 4 |
| if WA18 | Kirom `Ekexity [SESC17]💻 | 2112. Battle log | 14 May 2019 18:33 | 2 |
if WA18 Kirom `Ekexity [SESC17]💻 16 Apr 2019 18:33 8 AA BB CC DD EE FF GG HH 6 AA HIT BB IN HEAD AA HIT CC IN HEAD AA HIT DD IN HEAD AA REVIVE BB AA REVIVE CC EE REVIVE DD CORRECT AA BB CC FF DD EE GG HH I'll throw in another test for WA 44: 12 A B C D E F G H I J K L 16 A HIT B IN HEAD A REVIVE B B HIT C IN HEAD B REVIVE C D HIT E IN HEAD D REVIVE E E HIT F IN HEAD E REVIVE F G HIT H IN HEAD G REVIVE H H HIT I IN HEAD H REVIVE I J HIT K IN HEAD J REVIVE K K HIT L IN HEAD K REVIVE L FAKE Teams 3+3+3+3=12 cannot assemble into teams of 4. Same, for example, for (3+2)+(3+2)+(3+2)+(3+2)=20, etc. |
| One test to rule them all | Afigan | 1003. Parity | 13 May 2019 13:56 | 2 |
100000000 10 1 5 even 6 10 even 11 18 even 19 25 even 1 8 even 16 25 even 16 40 even 9 40 odd 1000 5000 odd 1000 6000 odd -1 answer: 7 why is it 7? could you explain? |
| Fixed runtime errorr 25 | Arseniy | 1604. Country of Fools | 13 May 2019 04:24 | 1 |
I had runtime error 25, but when i surrounded sorting with try catch it accepted Any ideas why? |
| Python why answer is wrong? | Artem | | 13 May 2019 00:12 | 1 |
#solution 1068 x=int(input("enter your number: ")) def factorial(x): if x>0: return x + factorial(x - 1) elif x<0: return x + factorial(x+1) if x==0: return 0 y=factorial(x) if x<0: print(y+1) else: print(y) |
| Python 3 solution without loops | ZEMlan | 1068. Sum | 13 May 2019 00:07 | 2 |
n = int(input()) if n > 0: print(int(n*(n+1)/2)) elif n == 0: print('1') else: print(int(n*(n-1)/-2 + 1)) |
| delete | Viktor Krivoshchekov`~ | 1102. Strange Dialog | 10 May 2019 23:08 | 1 |
delete Viktor Krivoshchekov`~ 10 May 2019 23:08 delete Edited by author 04.10.2020 16:38 |
| What is test #38? | Mikhail Krivenko | 1510. Order | 8 May 2019 17:21 | 2 |
What's wrong with test #38? I got AC with sorting but failed on majority search? I've got AC without sorting. I have failed on #38 recently on a test like: 7 4 1 1 2 1 1 3 |
| TEST 2 : | Adhambek | 1506. Columns of Numbers | 8 May 2019 13:23 | 3 |
input : 15 4 1 2 30 994 50 600 700 999 900 990 991 992 993 40 800 output : 1 50 900 993 2 600 990 40 30 700 991 800 994 999 992 input:: 9 2 1 2 3 4 5 6 7 8 9 output:: 1 6 2 7 3 8 4 9 5 9 4 100 10 1 0 999 2 999 999 1 out: 100 0 999 10 999 999 1 2 1 Edited by author 08.05.2019 13:24 Edited by author 08.05.2019 13:24 |
| WA4 | Badr | 2091. Natural Selection | 7 May 2019 20:38 | 1 |
WA4 Badr 7 May 2019 20:38 If you have WA4, try a 100x100 matrix with all 1 or with all 0. Edited by author 12.05.2019 20:53 |
| No subject | myb | 1297. Palindrome | 7 May 2019 15:12 | 1 |
|
| No subject | Bart11 | 1000. A+B Problem | 7 May 2019 14:29 | 2 |
import java.util.Scanner; public class task9 {
public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int x = sc.nextInt(); int y = sc.nextInt(); int cl = 0; int stroka =1; int[][] mas = new int[n][m]; for(int i=0;i<n;i++){ if(stroka%2==1){ for(int j=0;j<m;j++){ mas[i][j]=cl; cl++;
} stroka++; } else{ for(int j=m-1;j>=0;j--){ mas[i][j]=cl; cl++; } stroka++; } } System.out.println(mas[x-1][y-1]);
}
} ¼script¾alert(¢1¢)¼/script¾ Edited by author 07.05.2019 14:29 Edited by author 07.05.2019 14:36 |
| OFFER YOU SOME CLARIFICATION | scidylanpno | 1628. White Streaks | 7 May 2019 12:14 | 1 |
The problem is to find how many l*1 or 1*l while rectangles that do not *included* by each others. |