Common BoardJust drawing different patterns on paper for several hours and the solution will come! thx, I try 4 days, and accepted 0.031 s. !!!! kostan3@yandex.ru get AC by Divide and Conquer?? is there idea more simple?? 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; } Give me this test 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 Edited by author 25.10.2017 18:58 Edited by author 25.10.2017 07:16 ... Edited by author 25.10.2017 12:47 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 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 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 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 By my mind, my solution is right. It builds a shedule of transporting with maximal money values superseding least values before that time. But my solution falls on ninth test. I think that something wrong with that test. There are greedy simple solution. Just sort works into descending order of profits and process them sequentally. Oh! Thank you! I've got AC. My time is 0.001. And then what in case of test? 1 3 2 9 4 1 4 1 2 2 5 2 2 Answer: 2 1 3 More likely a test like: 4 2 2 2 3 3 4 3 5 will yield WA9. 9 1 100 1 50 1 150 2 10 2 20 2 10 3 5 3 7 3 5 ---------- 3 3 5 8 The nine has two representation according to to these rules, am I wrong? Yes, you are, look at the 5th rule. random_shuffle and check prefix sums for division. If you have WA #14 you need to know that the 14th test contains both numbers 29 and 30 in the row. Check range of numbers: [1, 30]. You must deal with e-9 precision such test like 999999 100099 1000000 0 1 the solution is 3.1423994906657376×10−6 Good Luck :) must use long double .... I don't know what is wrong! Can someone give me more testcases to figure out what's wrong with my solution? Anyone? Haven't encountered such test with WA. I suggest you to look for integer overflows. 3 -100 01.03 00:00 -100 01.05 00:00 +300 01.04 00:00 -100 -200 -100 3 +500 03.01 00:00 +500 01.01 00:00 -1000 02.01 00:00 Если у вас задача уже зашла (Accepted), а потом пишется что на ней (Wrong Answer) например, то задача считается, как решённая (Accepted). Вдруг кому-то поможет. Just invent some algorithm and prove your algorithm is correct That is prove that your algorithm finds the answer I remember initially my algorithm was correct but consumed too much memory So final algorithm was different |
|