Common Board| Show all threads Hide all threads Show all messages Hide all messages | | Is the sample correct? | AkemiHomura | 1046. Geometrical Dreams | 9 Apr 2011 09:21 | 1 | The problem suggests "The set of angles αi satisfies a condition that the sum of angles in any of its nonempty subsets is not aliquot to 360 degrees." However the sample gives "90 90 90"... | | WHAT ALGO??? | Steven Oldrich | 1775. Space Bowling | 9 Apr 2011 04:38 | 1 | Any hints on how to solve this problem?? | | Java | KALO | 1775. Space Bowling | 9 Apr 2011 04:38 | 3 | Java KALO 8 Apr 2011 19:00 Edited by author 09.04.2011 01:59 it seems easy :) Edited by author 09.04.2011 02:20 Re: Java Steven Oldrich 9 Apr 2011 04:38 Which algo to solve this problem?? Any hints plz | | N^2*log N solution gets TLE | Vitalii Arbuzov | 1147. Shaping Regions | 9 Apr 2011 00:42 | 1 | Hi all, i've used segment tree to solve this problem and got stuck with TLE 11. Maybe someone have idea of how to improve this solution to fit in time. Or one can provide test data that will get TLE locally. import java.util.Scanner; public class P1147 { private static final int MAX_COLORS = 2501; private static final short UNKNOWN = 0; private static long c[] = new long[MAX_COLORS]; private static final int TREE_SIZE = 1<<22; private static final int PARTITION_FACTOR = 10; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); short a = scanner.nextShort(); short b = scanner.nextShort(); short n = scanner.nextShort(); short[] tree = new short[TREE_SIZE]; Rectangle[] rectangles = new Rectangle[n + 1]; rectangles[0] = new Rectangle(0, 0, a, b, 1); for (short i = 1; i <= n; i++) { rectangles[i] = new Rectangle(scanner.nextShort(), scanner.nextShort(), scanner.nextShort(), scanner.nextShort(), scanner.nextShort()); } for (double iPartition = 0; iPartition < PARTITION_FACTOR - 1e-6; iPartition++) { for (double jPartition = 0; jPartition < PARTITION_FACTOR - 1e-6; jPartition++) { Rectangle partition = new Rectangle((int) (a * (iPartition / PARTITION_FACTOR)), (int) (b * (jPartition / PARTITION_FACTOR)), (int) (a * ((iPartition + 1) / PARTITION_FACTOR)), (int) (b * ((jPartition + 1) / PARTITION_FACTOR))); for (Rectangle rectangle : rectangles) { insert(tree, 0, rectangle, partition); } countColors(tree, 0, partition); } } for (int i = 0; i < MAX_COLORS; i++) { if (c[i] != 0) { System.out.println(i + " " + c[i]); } } } static void insert(short[] tree, int node, Rectangle rect, Rectangle region) { if (!rect.intersects(region) || !rect.isValid() || !region.isValid()) return; if (rect.contains(region)) { tree[node] = rect.color; } else { if (tree[node] == UNKNOWN) { int xMid = (region.x1 + region.x2) / 2; int yMid = (region.y1 + region.y2) / 2; insert(tree, node * 4 + 1, rect, new Rectangle(region.x1, region.y1, xMid, yMid)); insert(tree, node * 4 + 2, rect, new Rectangle(xMid, region.y1, region.x2, yMid)); insert(tree, node * 4 + 3, rect, new Rectangle(xMid, yMid, region.x2, region.y2)); insert(tree, node * 4 + 4, rect, new Rectangle(region.x1, yMid, xMid, region.y2)); } else { if (tree[node] == rect.color) return; Rectangle bottom = new Rectangle(region.x1, region.y1, region.x2, rect.y1, tree[node]); Rectangle top = new Rectangle(region.x1, rect.y2, region.x2, region.y2, tree[node]); Rectangle left = new Rectangle(region.x1, rect.y1, rect.x1, rect.y2, tree[node]); Rectangle right = new Rectangle(rect.x2, rect.y1, region.x2, rect.y2, tree[node]); tree[node] = UNKNOWN; insert(tree, node, rect, region); insert(tree, node, bottom, region); insert(tree, node, top, region); insert(tree, node, left, region); insert(tree, node, right, region);
} } private static void countColors(short[] tree, int node, Rectangle region) { if (!region.isValid()) return; if (node >= TREE_SIZE) return; if (tree[node] != UNKNOWN) { c[tree[node]] += region.area(); } else { int xMid = (region.x1 + region.x2) / 2; int yMid = (region.y1 + region.y2) / 2; countColors(tree, node * 4 + 1, new Rectangle(region.x1, region.y1, xMid, yMid)); countColors(tree, node * 4 + 2, new Rectangle(xMid, region.y1, region.x2, yMid)); countColors(tree, node * 4 + 3, new Rectangle(xMid, yMid, region.x2, region.y2)); countColors(tree, node * 4 + 4, new Rectangle(region.x1, yMid, xMid, region.y2)); } } static class Rectangle { short x1, y1, x2, y2, color; Rectangle(int x1, int y1, int x2, int y2, int color) { this.x1 = (short) x1; this.y1 = (short) y1; this.x2 = (short) x2; this.y2 = (short) y2; this.color = (short) color; } public Rectangle(int x1, int y1, int x2, int y2) { this(x1, y1, x2, y2, UNKNOWN); } boolean intersects(Rectangle other) { return other.x1 < this.x2 && other.x2 > this.x1 && other.y1 < this.y2 && other.y2 > this.y1; } boolean contains(Rectangle other) { return (other.x1 >= this.x1) && (other.x2 <= this.x2) && (other.y1 >= this.y1) && (other.y2 <= this.y2); } boolean isValid() { return x1 < x2 && y1 < y2; } long area() { return (x2 - x1) * (y2 - y1); } } } Many thanks, Vitaliy | | Give some more tests... | mastermana | 1726. Visits | 8 Apr 2011 15:21 | 1 | I need more samples... I thought I understood, but when I submitted the task, I got WA, so, can you give some more samples, for me to get an idea? | | WA11 | Soucup Adrian | 1041. Nikifor | 8 Apr 2011 05:51 | 1 | WA11 Soucup Adrian 8 Apr 2011 05:51 I do calculations on a ring of integers modulo (big prime). If i change the prime number sometimes i get WA on test 9. Any suggestions? ..... Got AC. Edit: Found a silly mistake. I thought is about the prime, but it wasn't. Edited by author 08.04.2011 06:41 | | C++ hint | ASK | 1732. Ministry of Truth | 8 Apr 2011 03:04 | 3 | KISS! There is no TA even if you use: from.find(to.substr(to_position, length), from_position) What is TA.. I use it and i have WA on 5th test. KISS! There is no TA even if you use: from.find(to.substr(to_position, length), from_position) KISS! There is no TA even if you use: from.find(to.substr(to_position, length), from_position) I use KMP algorithm but I have WA 9 ... any ideea? Edited by author 08.04.2011 03:05 | | WA #17 | mastermana | 1769. Old Ural Legend | 8 Apr 2011 01:52 | 1 | WA #17 mastermana 8 Apr 2011 01:52 I checked the code, and all the test given here, and it gives true answers, but I don't know why I get WA on 17... Can you give some more tests that are similar to 17 so I can see where is my mistake? | | WA #6. Please give some test | Rashad | 1769. Old Ural Legend | 7 Apr 2011 19:47 | 6 | My program works well, but I have WA on test 6 please give some tests This test may help~ 0001002003004005006007008009011012013014015016017018019021022023024025026027028029031032033034035036037038039041042043044045046047048049051052053054055056057058059061062063064065066067068069071072073074075076077078079081082083084085086087088089091092093094095096097098099111211311411511611711811912212312412512612712812913213313413513613713813914214314414514614714814915215315415515615715815916216316416516616716816917217317417517617717817918218318418518618718818919219319419519619719819922232242252262272282292332342352362372382392432442452462472482492532542552562572582592632642652662672682692732742752762772782792832842852862872882892932942952962972982993334335336337338339344345346347348349354355356357358359364365366367368369374375376377378379384385386387388389394395396397398399444544644744844945545645745845946546646746846947547647747847948548648748848949549649749849955565575585595665675685695765775785795865875885895965975985996667668669677678679687688689697698699777877978878979879988898999001000100100210031004100510061007100810091010110121013 the answer should be 1014 you may get 300 if you keep getting wrong on the test 6 good luck~ thanks ) sorry I had another problem, now it works right, but I have TLE, my algo is not fast ( my program gives 1014 on this test, but I have WA#2 ( I have right answer on this test, but WA#6. WTF? Edited by author 17.04.2010 10:19 0 is not positive integer! So if ur output is 0 its wrong answer... That might cause u a problem on test 2 Edited by author 07.04.2011 19:50 | | WA #13. Please give me some tests ! | Anastas | 1212. Battleship | 7 Apr 2011 16:38 | 3 | 7 7 4 3 3 1 V 5 3 1 H 3 5 1 H 5 5 1 V 1 Ans:24 | | Wrong answer... | Cross | 1001. Reverse Root | 7 Apr 2011 12:47 | 2 | What's wrong? program Project1; {$APPTYPE CONSOLE} uses SysUtils; var i,n:integer; data:string; tmp:array of string; begin readln(data); n:=0; SetLength(tmp,length(data)+1); for i:= 1 to length(data) do begin if not(data[i]=' ')then tmp[n]:=tmp[n]+data[i]; if (data[i]=' ')and (data[i+1]<>' ')then n:=n+1; end; for i:=n downto 1 do writeln(sqrt(StrToFloat(tmp[i])):0:4); readln; end. for i:=n downto 0 do writeln(sqrt(StrToFloat(tmp[i])):0:4); Edited by author 07.04.2011 12:47 | | wa43? | mikewu | 1641. Duties | 7 Apr 2011 09:19 | 1 | wa43? mikewu 7 Apr 2011 09:19 could you test it again? i've no idea whats wrong | | WA#1 | adavydow | 1630. Talisman | 6 Apr 2011 07:09 | 1 | WA#1 adavydow 6 Apr 2011 07:09 Why output to syserr cause wa#1? Is it working as intended? | | Hint for those who have TLE | Vedernikoff Sergey (HSE: АОП) | 1775. Space Bowling | 6 Apr 2011 06:54 | 2 | In the final loop, when you count the number of circles which the given line touches, use only + and * operations (without divisions and - OMG - square roots) - this will speed your code up several times. Edited by author 13.10.2010 21:13 Throught what set of lines should i iterate?? Help pls | | Is there a faster algorithm? | olpetOdessaONU [1 2/3] | 1775. Space Bowling | 6 Apr 2011 06:53 | 3 | I wrote a solution with complexity of O(n^3 log n) and got AC for 0.75 sec. Is there a solution for O(n^3) or O(n^2 log n)? I have O ( N ^ 3 * LogN )and got AC for 0.234s, you can just optimize it. I can't think of a solution with better complexity. Have u used stabbing line problem variation? What algo have u used to solve this problem | | It's a beautiful problem. Thanks to author. | Alex Tolstov (Vologda STU) | 1696. Salary for Robots | 6 Apr 2011 01:26 | 2 | | | What's on test 15? | Gio Pataraia [Tbilisi SU] | 1723. Sandro's Book | 6 Apr 2011 01:20 | 2 | :X i have implemented wrong max function and that's was my mistake :(( Edited by author 06.04.2011 01:20 | | Why this code have WA on test13? | acm_tester | 1820. Ural Steaks | 6 Apr 2011 00:14 | 5 | Why this code have WA on test13? Please give me a test when this program fail. var N,K:longint; begin readln(N,K); if k>N then n:=k; N:=2*N; if N mod K = 0 then writeln(N div K) else writeln(N div K + 1); end. change 'readln' into 'read' and 'writeln' into 'write' and you'll get AC Good luck =D Edited by author 20.03.2011 10:37 Really, I just change readln to read and give AC. But in the text of problem: ENG: The only input line contains the integers n and k separated with a space RUS: В единственной строке через пробел записаны целые числа n и k Why readln is wrong in this input??? 1820. Уральские бифштексы Ограничение времени: 0.5 секунды Ограничение памяти: 64 МБ #include <iostream> using namespace std; void main() { int N,K,p; cin>>N>>K; if(K>N) N=K; N=2*N; if((N%K)==0) cout<<N/K; else cout<<(N/K)+1; } | | WA 14 | mikewu | 1500. Pass Licenses | 5 Apr 2011 09:21 | 3 | WA 14 mikewu 5 Apr 2011 04:25 need some test plz. no idea whats wrong. thanks. As far as I know, 14 requires the maximum of 20 licenses - which may or may not be an issue for you. It was why I got WA 14. thank you. It is indeed the issue i have. | | Radiaotion | Aleksandar Ralic | 1553. Caves and Tunnels | 5 Apr 2011 03:52 | 2 | Is the radiation between two consecutive caves zero? Edited by author 05.04.2011 03:43 |
|
|