Common Board| Show all threads Hide all threads Show all messages Hide all messages | | Little help for solve by Python (dict of numbers) | sergovoy | 2081. Faulty dial | 28 Oct 2017 12:20 | 3 | d = {'._.\n|.|\n|_|': 0, '...\n..|\n..|': 1, '._.\n._|\n|_.': 2, '._.\n._|\n._|': 3, '...\n|_|\n..|': 4, '._.\n|_.\n._|': 5, '._.\n|_.\n|_|': 6, '._.\n..|\n..|': 7, '._.\n|_|\n|_|': 8, '._.\n|_|\n._|': 9 } 7590680 - Топ среди Питона 3 по использованию памяти) | | all is ok,but why getting wrong answer??C language | Chowdhury Md. Ishmam Rahman | 1068. Sum | 28 Oct 2017 12:00 | 2 | #include<stdio.h> #include<math.h> int main() { int i,sum=0,n; scanf("%d",&n); if(abs(n)<=10000){
if(n<0){
for(i=1;i>=n;i--){ sum+=i; } } else{ sum=((n*n)+n)/2; } printf("%d",sum);} return 0; } Your code is almost okay.It's wrong only for one test case. When n=0 then according to your code output will be 0.But right answer is 1. Please check again output condition of this problem. Otherwise https://ideone.com/Q6C1gh | | mathmatical problem, just use program output answer | clyde | 1009. K-based Numbers | 28 Oct 2017 11:38 | 1 | | | Result | Ion | 2056. Scholarship | 27 Oct 2017 19:35 | 1 | #include <stdio.h> #include <stdlib.h> int main() { int a,p=0,i,*b; float f,s=0; scanf("%d",&a); b=(int *)malloc(sizeof(int)*a); for(i=0;i<a;i++){ scanf("%d",&b[i]);} /*if (b[i]<3||b[i]>5) scanf("%d",&b[i]); }*/ for(i=0;i<a;i++) s+=b[i]; f=s/a; for(i=0;i<a;i++) { if(b[i]==3){ p=1;} } if(f==5) {printf("Named"); } else if(f>=4.5&&p==0){ printf("High"); } else if(f<4.5&&p==0){ printf("Common");} else {printf("None");} free(b); return 0; } | | WA #14 please help | James Gregory | 1998. The old Padawan | 27 Oct 2017 08:19 | 1 | I've passed all of the user tests on here, and any test I can think of. Still getting WA on #14. Here's my non-working code. import java.io.*; public class P1998 { static StreamTokenizer in; static PrintWriter out;
static int nextInt() throws IOException{ do{ in.nextToken(); }while(in.ttype != StreamTokenizer.TT_NUMBER); return (int)in.nval; }
public static void main(String[] args) throws IOException{ in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out);
int n = nextInt(); int m = nextInt(); int k = nextInt();
int[] stones = new int[n]; int[] dropsTo = new int[n];
int tmp = 0, j = 0; for(int i = 0; i < n; i++){ stones[i] = nextInt();
while(j < i - 1 && tmp - stones[j] > k){ tmp -= stones[j]; j++; } tmp += stones[i]; dropsTo[i] = j; }
j = 0; int moment, time = 0; for(int i = 0; i < m; i++){ moment = nextInt() - time; time += moment; j += moment - 1; if(j >= n){ time -= moment - n; j = n; break; } j = dropsTo[j]; }
out.println(time + n - j); out.flush(); } } | | MY AC Solution 0.203 (Be careful, spoilers!) | KOTMAKRUS | 1196. History Exam | 27 Oct 2017 01:58 | 3 | Create an array of Boolean elements. Size = billion. For i:=1 to n {{ introduce a variable; element of array with index [variable] equals true }} For i:=1 to m {{ introduce a variable; if element of array with index [variable] equals true then increase the counter }} And finally, we output counter)) That's all), sorry for bad english But this solution takes 58 mb of memory... (( Edited by author 06.04.2014 16:17 Then, your code is just using a hash table method. But I check the solution rating, someone can do it in 0.015, and many persons do it below 0.1. How can they do that? Is because that compiler different? Then, your code is just using a hash table method. But I check the solution rating, someone can do it in 0.015, and many persons do it below 0.1. How can they do that? Is because that compiler different? It's not that hard to do it under 0.1 with C. Decent hash implementation and optimized input reading (scanf is too slow!) will actually do the 0.031 trick. 0.062 is achievable with a binary search. I achieved 0.015 by optimizing things speedwise a bit more and using as much memory as was allowed. (studied just for fun a bit how slightly different schemes perform, have to try a few more ideas later, my current 0.015 solution is far from the optimum.) | | Getting TLE test 27 | Shubham | 2070. Interesting Numbers | 26 Oct 2017 23:09 | 1 | Used Sieve to generate primes till 10^6, and then used those primes to generate larger primes. counted all such numbers satisfying L <= p^(q-1) <=R where p & q are primes (q>2). Subtracted it from R-L+1 How to optimize? | | WA 4 | BIGfoot | 1242. Werewolf | 26 Oct 2017 21:38 | 1 | WA 4 BIGfoot 26 Oct 2017 21:38 I got WA on test 4, but on all tests I could make myself and also on those, which were in the problem, my program answered correctly. Please, suggest some tests, that could help. | | What is wrong with this solution? Judge is giving output as Wrong Answer | nahusha | 1001. Reverse Root | 26 Oct 2017 19:50 | 1 | import java.util.Scanner; import java.util.Stack; public class ReverseRoot_SplitDecimal {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in); Stack<Integer> integerNumberStack = new Stack<Integer>(); Stack<Short> floatingNumberStack = new Stack<Short>();
Double tempDouble = new Double(0);
while(sc.hasNextInt()) { tempDouble = Math.sqrt(sc.nextDouble()); integerNumberStack.push(Integer.parseInt(String.format("%.4f", tempDouble).split("\\.")[0])); floatingNumberStack.push(Short.parseShort(String.format("%.4f", tempDouble).split("\\.")[1])); }
while(!integerNumberStack.isEmpty()) { System.out.printf("\n%d.%04d", integerNumberStack.pop(), floatingNumberStack.pop()); } System.out.println();
sc.close(); } } | | How to solve | Zurg | 1674. Drunk King | 26 Oct 2017 12:35 | 4 | Just drawing different patterns on paper for several hours and the solution will come! thx, I try 4 days, and accepted 0.031 s. !!!! get AC by Divide and Conquer?? is there idea more simple?? | | To admins: Go gets WA1, C++ gets AC | Slava Shklyaev | 1307. Archiver | 26 Oct 2017 09:09 | 2 | My solutions in the two languages produce the same output on my tests. However, the Go version gets WA1. Please fix this. #include<iostream> #include <stdio.h> #include <stdlib.h> #include <string> using namespace std; int main() { long l; string a,b; cin>>a; l=a.length(); if((l>=10)&&(l<=189)) { b=a.substr(l-2,2);
} else if((l>=190)&&(l<=2700)) b=a.substr(l-3,3); else if((l<=2701)&&(l<=36000)) b=a.substr(l-4,4); else b=a.substr(l-5,5); cout<<"//CPP"<<endl; cout<<"#include<iostream.h>"<<endl; cout<<"int main()"<<endl; int i = atoi(b.c_str()); cout<<"{for(int i=1;i<"<<i+1<<";i++)cout<<i;return 0;}"; return 0; } | | WA test 5 | McArchuk | 1651. Shortest Subchain | 26 Oct 2017 08:35 | 4 | My solution give correct answer on all test in topic WA test 7, but i have WA test 5 from judge system. 12 1 2 3 4 2 1 5 8 9 2 10 6 Correct answer: 1 2 10 6 8 1 2 3 4 5 2 3 6 answer: 1 2 3 6 | | No subject | James Gregory | 1992. CVS | 25 Oct 2017 18:19 | 1 | Edited by author 25.10.2017 18:58 | | No subject | James Gregory | 2015. Zhenya moves from the dormitory | 25 Oct 2017 07:08 | 1 | Edited by author 25.10.2017 07:16 | | WA#3 | [kubsu] Eugene Kudinov | 1951. Complex Root | 25 Oct 2017 01:35 | 1 | WA#3 [kubsu] Eugene Kudinov 25 Oct 2017 01:35 ... Edited by author 25.10.2017 12:47 | | 2nd test | Kurbatov Egor | 2080. Wallet | 24 Oct 2017 19:29 | 1 | 2nd test Kurbatov Egor 24 Oct 2017 19:29 | | Test 2 is incorrect! | P_Nyagolov | 1008. Image Encoding | 24 Oct 2017 12:37 | 3 | The following code: cin>>n; for(i=1;i<=n;i++) { cin>>x[i]>>y[i]; assert(x[i]>=1 && x[i]<=10 && y[i]>=1 && y[i]<=10); here[x[i]][y[i]]=true; } gives RTE, so test 2 is wrong. After, removing the assert, it gives WA :) Input One representation of the image will be given to your program in the input. Output Your program has to write other representation of the image to the output. The following code: cin>>n; for(i=1;i<=n;i++) { cin>>x[i]>>y[i]; assert(x[i]>=1 && x[i]<=10 && y[i]>=1 && y[i]<=10); here[x[i]][y[i]]=true; } gives RTE, so test 2 is wrong. After, removing the assert, it gives WA :) TEST 2 like this : Input: 2 3 RT, RT, , B, , . Output: 6 2 3 2 4 3 3 3 4 4 2 4 3 | | I publish the correct code, but the timus does not accept it, so that everything is normal. | Bushmanov | 2023. Donald is a postman | 24 Oct 2017 03:59 | 3 | Hello. Task number is 2023. Timus flatly refuses to accept. He had a lot of tests, but he did not find any flaws. Maybe someone will tell me, otherwise I'll kill myself tomorrow. n = int(input()) zn = [1] k=0 y = 0 sh1 = ('Alice', 'Ariel', 'Aurora', 'Phil', 'Peter', 'Olaf', 'Phoebus', 'Ralf', 'Robin') sh2 = ('Bambi', 'Belle', 'Bolt', 'Mulan', 'Mowgli', 'Mickey', 'Silver', 'Simba', 'Stitch') for j in range (n): i = input() if i in sh1: zn.append (1) elif i in sh2: zn.append (2) else: zn.append (3) n-=1 for k in range (len(zn)): y+= abs ((int(zn [k-1]))-int(zn [k])) lop = y-zn[-1]+1 print (lop) >'Ralf' Every time someone has problems with this task, it's someone who can't type text from a picture properly. Thank you. (Cnacu6o, Bbl Mou repou!) Edited by author 24.10.2017 04:00 | | What's wrong with my algo? | Akaishuichi | 1229. Strong Brickwork | 23 Oct 2017 22:08 | 3 | Finally ACed by changing to a direct approch. But I still don't understand what's wrong with my previous algo(which results to WA5) It's something like this: For example, for such a input: 4 6 1 1 2 3 3 7 4 5 2 6 6 7 4 5 8 9 12 11 10 10 8 9 12 11 1.Construct a n*m graph G, every vertices connected with all it's neighbors(up, down, left, right) (for layout reasons here I use hex to number the vertices) (the graph left is only a illustration to explain the things happening to the former graph. the graph right shows the result we get in every stage.) 1-1-2-3-3-7 o-o-o-o-o-o | | | | | | | | | | | | 4-5-2-6-6-7 o-o-o-o-o-o | | | | | | | | | | | | 4-5-8-9-C-B o-o-o-o-o-o | | | | | | | | | | | | A-A-8-9-C-B o-o-o-o-o-o 2.Remove an edge whose endpoints have the same number. Repeat this operation until no such pairs connected. finally we get something like this 1 1-2-3 3-7 o o-o-o o-o | | | | | | | | 4-5-2-6 6-7 o-o-o-o o-o | | | | | | | | 4-5-8-9-C-B o-o-o-o-o-o | | | | A A-8-9-C-B o o-o-o-o-o 3.Pick a vertex v, which has a minimum degree(non-zero), and w, an arbitrary neighbor of v. Assign a incremental number to both v and w, and remove all the edges who cover v or w. Repeat this operation until Δ(G) == 0. For the input the process will be: (STEP1) 1 1-2-3 3-7 1 o-o-o o-o | | | | | | | 4-5-2-6 6-7 1 o-o-o o-o | | | | | | | | 4-5-8-9-C-B o-o-o-o-o-o | | | | A A-8-9-C-B o o-o-o-o-o (STEP2) 1 1-2-3 3 7 1 o-o-o 2 2 | | | | 4 5-2-6 6-7 1 o-o-o o-o | | | | | | | | 4-5-8-9-C-B o-o-o-o-o-o | | | | A A-8-9-C-B o o-o-o-o-o (STEP3) 1 1-2-3 3 7 1 o-o-o 2 2 | | | | 4 5-2-6 6-7 1 o-o-o o-o | | | | | | | | 4 5-8-9-C-B 3 o-o-o-o-o | | A A-8-9-C-B 3 o-o-o-o-o (STEP4) 1 1-2-3 3 7 1 o-o-o 2 2 | | | | 4 5-2-6 6-7 1 o-o-o o-o | | | | | | | | 4 5-8-9-C-B 3 o-o-o-o-o | | A A-8-9 C B 3 o-o-o 4 4 (STEP5) 1 1-2-3 3 7 1 o-o-o 2 2 | | | | | 4 5-2-6 6-7 1 o-o-o o-o | | | | | | | | 4 5-8-9-C-B 3 o-o-o-o-o | | A A 8 9 C B 3 o 5 5 4 4 (STEP6) 1 1-2-3 3 7 1 o-o-o 2 2 | | | | | 4 5-2-6 6-7 1 o-o-o o-o | | | | | | | | 4 5 8-9-C-B 3 6 o-o-o-o
A A 8 9 C B 3 6 5 5 4 4 (STEP7) 1 1 2 3 3 7 1 7 7 o 2 2 | | 4 5-2-6 6-7 1 o-o-o o-o | | | | | | | | 4 5 8-9-C-B 3 6 o-o-o-o
A A 8 9 C B 3 6 5 5 4 4 (STEP8) 1 1 2 3 3 7 1 7 7 o 2 2 | | 4 5 2 6 6-7 1 8 8 o o-o | | | | | | 4 5 8-9-C-B 3 6 o-o-o-o
A A 8 9 C B 3 6 5 5 4 4 (STEP9) 1 1 2 3 3 7 1 7 7 9 2 2
4 5 2 6 6-7 1 8 8 9 o-o | | | | 4 5 8-9-C-B 3 6 o-o-o-o
A A 8 9 C B 3 6 5 5 4 4 (STEP10) 1 1 2 3 3 7 1 7 7 9 2 2
4 5 2 6 6-7 1 8 8 9 o-o | | | | 4 5 8 9 C-B 3 6 A A o-o
A A 8 9 C B 3 6 5 5 4 4 (STEP11) 1 1 2 3 3 7 1 7 7 9 2 2
4 5 2 6 6 7 1 8 8 9 B B
4 5 8 9 C-B 3 6 A A o-o
A A 8 9 C B 3 6 5 5 4 4 (STEP12) 1 1 2 3 3 7 1 7 7 9 2 2
4 5 2 6 6 7 1 8 8 9 B B
4 5 8 9 C B 3 6 A A C C
A A 8 9 C B 3 6 5 5 4 4 4.Finally we got a valid output: 1 7 7 9 2 2 1 8 8 9 B B 3 6 A A C C 3 6 5 5 4 4 I know I must mistaked something, but I can't find the mistake. Please tell me where is wrong, or give me some tests to beat this algo. Thanks in advance. Edited by author 31.05.2009 00:28 Sorry Akaishuichi 31 May 2009 00:32 I'm sorry the layout turned out to be totally unreadable. Please copy the text to the notepad for viewing the graph edges. It was a very good question. What's wrong with the algo? "3. Pick a vertex v, which has a minimum degree (non-zero)..." If there are several (not one) such vertices, we must do a choice. Let choose the vertix (with a minimum degree) that is placed in the least row. If the row has several vertices with a minimum degree, let choose the vertix that is placed in the least column. The next choice is the choice of w (see the algo). Let choose right neighbor of v if v is connected with it. Otherwise let choose bottom neighbor of v as w. So we have input data that breaks the algo: 6 6 1 1 2 2 3 4 5 5 6 7 3 4 8 9 6 7 10 11 8 9 12 12 10 11 13 14 15 15 16 17 13 14 18 18 16 17 STEP 12 1 9 9 3 2 2 1 10 10 3 11 11 4 4 o - o 12 12 | | o - o - o o - o - o | | | | o - o 6 8 o - o 5 5 6 8 7 7 STEP 13 (it is not good) 1 9 9 3 2 2 1 10 10 3 11 11 4 4 13 13 12 12
o - o - o o - o - o | | | | o - o 6 8 o - o 5 5 6 8 7 7 I'm sure we can build input data that makes the algo invalid if we would choose the v and w in other way. Edited by author 23.10.2017 22:15 | | WA #33 | Dmitri Belous | 1574. Mathematicians and brackets | 21 Oct 2017 19:40 | 1 | WA #33 Dmitri Belous 21 Oct 2017 19:40 |
|
|