Common BoardIf you have a problem - WA4 - consider sorting input, not output for example: 5 1 5 3 6 1 3 9 6 4 2 answer 3 1 3 3 6 6 9 I pass the test,But I still got WA#4 thanks for helping me solve WA 1 Edited by author 19.11.2013 20:56 Thanks, it was very useful to getting AC. #include <iostream> using namespace std; int main() { int n = 0, m = 0, a = 0, s = 0, k = 0; int arr[15001]; cin >> n; for(int i = 0; i < n; i ++) { cin >> arr[i]; } cin >> m; bool flag = true; int j = 0; int left = 0, right = n-1; for(int i = 0; i < m; i++) { cin >> a; j = 0; left = 0; right = n-1; flag = true; if(a == arr[0]) { flag = false; s++; } else { if(a == arr[n-1]) { flag = false; s++; } } if(a > arr[n-1]) { flag = false; } while(flag) { if(a > arr[j]) { left = j; j = (left + right)/2; if(a == arr[j]) { { flag = false; s++; } } if(right-left <= 1) { flag = false; if(a == arr[j+1]) s++; } } else { right = j; j = (left + right)/2; if(a == arr[j]) { { flag = false; s++; } } if(right-left <= 1) { flag = false; if(a == arr[j+1]) s++; } } } } cout << s; return 0; } Edited by author 17.11.2013 16:03 Публикация решений запрещена правилами. С чего бы это? Запрещено выкладывать решения заданий из текущего соревнования до его окончания. RTFM: 1. Messages should be written in English and correspond to the matter of the site. 2. Messages should not contain offences and obscene words. 3. Messages should not contain correct solutions. 1. Сообщения должны быть написаны на английском языке и соответствовать тематике сайта. 2. Сообщения не должны содержать оскорблений и нецензурной лексики. 3. Сообщения не должны содержать правильных решений. My damned solution keep giving WA on test 6 with C11. I tested on big numbers and every corner case (yes, it works with 1 1 -> '0', yes, it gives '-1' on 3 6, etc..) Suggestions? What's in test 6? The exact same algorithm in python gives AC.. (and it's not a bignum issue, I tested the C version with 43 and 10**9) Edited by author 24.11.2013 01:26 give some tests plz 1 35 0 25 21 22 Answer YES Edited by author 12.04.2009 20:28 I think that the correct answer here is NO wtf Edited by author 12.04.2009 20:32 I'm sorry, I made mistake. Though my lying AC programm writes "YES" ((((. Test is changed. Maybe answer on test 1 35 0 25 22 21 is also "YES" ? Anybody, check it, plz. Hi, My program gives "YES", I got WA#12 also. Any ideas? AC program. answer is YES I use BFS, but WA12 :( Help me, pleas give me test var a,b:array[1..1000000] of integer; f:array[1..1000000]of integer; n,v,e,k,u:integer; begin k:=0; assign(input, 'input.txt'); reset(input); assign(output, 'output.txt'); rewrite(output); readln(n); for v:=1 to n do begin read(a[v]); read(b[v]); readln end; for e:=n downto 1 do begin f[e]:=a[e]+b[e]; f[e]:=f[e]+k; if f[e]>9 then begin f[e]:=f[e]-10; k:=1; end else k:=0; if((e=1)and(f[e]>9)) then f[e]:=f[e]+10; end; for u:=1 to n do write(f[u]); end. var a,b:array[1..1000000] of integer; f:array[1..1000000]of integer; n,v,e,k,u:integer; begin k:=0; readln(n); for v:=1 to n do begin read(a[v]); readln(b[v]); end; for e:=n downto 1 do begin f[e]:=a[e]+b[e]; f[e]:=f[e]+k; if f[e]>9 then begin f[e]:=f[e]-10; k:=1; end else k:=0; if((e=1)and(f[e]>9)) then f[e]:=f[e]+10; end; for u:=1 to n do write(f[u]); end. You shouldn't using input,output in your solution. But i can't find your mistake too... Edited by author 24.05.2011 23:51 Edited by author 24.05.2011 23:52 if((e=1)and(f[e]>9)) then f[e]:=f[e]+10; f[e]>9... Why do you plus 10? Sorry, I am Russian. New timelimit is 1.5 seconds. All solutions were rejudged. I found a test that might be you don't have: input: 2 AA output: 2.000 my program accepted even it's not passed this test. plase add this test as a variant Your test was added. Thanks. I'm getting WA#4, can you give some tests? 1 1 1 King: 0 Knight: 0 Bishop: 0 Rook: 0 Queen: 0 2 2 2 King: 3 Knight: 0 Bishop: 1 Rook: 2 Queen: 3 100000000 99999999 100000000 King: 5 Knight: 3 Bishop: 99999999 Rook: 199999998 Queen: 299999997 98765432 10987654 32109876 King: 8 Knight: 8 Bishop: 120740737 Rook: 197530862 Queen: 318271599 Thank you, remembered about cases when n<4 until your post. Got AC! Have you used predefined output for these (n<4) cases? Edited by author 16.11.2013 03:51 No, well designed algo equally works for all possible cases If they both start from the same position, who eats the number from that position? If somebody has the same question - the first one eats the number. #include "stdafx.h" #include "stdio.h" #include "locale.h" int main() { setlocale(LC_CTYPE, "rus"); int X, Z;
char Y; printf("Введите координаты клетки коня: "); scanf("%c%d", &Y, &Z); switch (Y) { case 'a': Y = 1; break; case 'b': Y = 2; break; case 'c': Y = 3; break; case 'd': Y = 4; break; case 'e': Y = 5; break; case 'f': Y = 6; break; case 'g': Y = 7; break; case 'h': Y = 8; break; default: break; }
if (Y == 1 && Z == 1 || Y == 1 && Z == 8 || Y == 8 && Z == 1 || Y == 8 && Z == 8) { printf("Клеток под боем: 2\n"); } else { if (Y == 1 && Z == 2 || Y == 1 && Z == 7 || Y == 2 && Z == 1 || Y == 2 && Z == 8 || Y == 7 && Z == 1 || Y == 7 && Z == 8 || Y == 8 && Z == 2 || Y == 8 && Z == 7) { printf("Клеток под боем: 3\n"); } else { if (Y == 1 && Z == 3 || Y == 1 && Z == 4 || Y == 1 && Z == 5 || Y == 1 && Z == 6 || Y == 8 && Z == 3 || Y == 8 && Z == 4 || Y == 8 && Z == 5 || Y == 8 && Z == 6 || Z == 1 && Y == 3 || Z == 1 && Y == 4 || Z == 1 && Y == 5 || Z == 1 && Y == 6 || Z == 8 && Y == 3 || Z == 8 && Y == 4 || Z == 8 && Y == 5 || Z == 8 && Y == 6 || Y == 2 && Z == 2 || Y == 2 && Z == 7 || Y == 7 && Z == 2 || Y == 7 && Z == 7) { printf("Клеток под боем: 4\n"); } else { if (Y == 2 && Z == 3 || Y == 2 && Z == 4 || Y == 2 && Z == 5 || Y == 2 && Z == 6 || Y == 7 && Z == 3 || Y == 7 && Z == 4 || Y == 7 && Z == 5 || Y == 7 && Z == 6 || Z == 2 && Y == 3 || Z == 2 && Y == 4 || Z == 2 && Y == 5 || Z == 2 && Y == 6 || Z == 7 && Y == 3 || Z == 7 && Y == 4 || Z == 7 && Y == 5 || Z == 7 && Y == 6) { printf("Клеток под боем: 6\n"); } else { if (Y == 3 && Z == 3 || Y == 3 && Z == 4 || Y == 3 && Z == 5 || Y == 3 && Z == 6 || Y == 4 && Z == 3 || Y == 4 && Z == 4 || Y == 4 && Z == 5 || Y == 4 && Z == 6 || Y == 5 && Z == 3 || Y == 5 && Z == 4 || Y == 5 && Z == 5 || Y == 5 && Z == 6 || Y == 6 && Z == 3 || Y == 6 && Z == 4 || Y == 6 && Z == 5 || Y == 6 && Z == 6) { printf("Клеток под боем: 8\n"); } else { printf("Где конь, парень? 0_о \n"); } } } } } return 0;
} what's wrong, guys? :D P.S.: WA 1 Hi, you shouldn't print out anything else than the requested number. Please remove the messages in russian from the printf. HAHA made my day :D:D:D Где конь, парень? 0_о WOW! :D My algorithm finds the numbers on the left and right, and then compares them, and takes a step toward greater. But if the sum is equal, it compares to one until it finds one larger (and goes upwards). If comparing the results in one step, then goes in the direction of the enemy. What's wrong? Try these tests first test: 10 0 0 1 10 5 100 5 1 0 0 3 8 answer: 16 106 second test 10 0 0 1 100 5 10 5 1 0 0 3 8 106 16 answer: 106 16 I am slowpock. I go AC. Edited by author 17.11.2013 02:14 On #1 test my program output: 4 6 1 5 4 but get wrong answer. Why? Your progression is decreasing (9 7 5 3), which contravenes the problem statement: "You should take a maximal number of different elements from this sequence which are successive terms of some increasing arithmetical progression." Thank you, i'll correct my mistake import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); String[] a = new String[n]; int[] result = new int[n]; for (int i = 0 ; i < n ; i++){ String tmp = in.next(); String x = tmp.substring(0,1); String y = tmp.substring(1,2); int xi=0; ArrayList<String> letters = new ArrayList<String>(); Collections.addAll(letters, "a", "b", "c", "d", "e", "f", "g", "h"); xi = letters.indexOf(x); int yi = Integer.parseInt(y)-1; int[][] desk = new int[8][8]; for (int[] tmp_array :desk){ Arrays.fill(tmp_array,1); } result[i]=0; result[i]=result[i] + check(desk,xi+1,yi+2)+ check(desk,xi+2,yi+1)+ check(desk,xi-1,yi+2)+ check(desk,xi-2,yi+1)+ check(desk,xi+1,yi-2)+ check(desk,xi+2,yi-1)+ check(desk,xi-1,yi-2)+ check(desk,xi-2,yi-1); } for (int j : result){ out.println(j); } out.flush(); } public static int check(int[][] desk, int x, int y){ int add = 0; try{ if (desk[x][y]==1){ add++; } }catch (Exception e){} return add; } } Why? #include <iostream> using namespace std; int main () { int x,y=0; cin >> x; if (x==1) { cout << x-1; return 0; system ("pause > void"); } if (x>1 && x<=10000) { for (int z=1;z<=x;++z) { y+=z; } } if (x<1 && x>=-10000) { for (int z=x;z<=1;++z) { y+=z; } } cout << y; system ("pause > void"); } Edited by author 10.11.2013 23:05 For x=1 your output is wrong; why do you print x-1? ok,THX)) if x=1,cout x or 1 Edited by author 15.11.2013 18:51 Cual es la entrada y salida del test 4? Hi there, test 4 is quite small actually, so take a look for possibilities that your code enters an infinite loop. Kornilenko Leonid (KHAI) AC [1] // Problem 1563. Bayan 22 Jan 2008 17:13 0.062s and 2125Kb I solve it on C#. With Hashtable it's very easy. p.s. GL & HF Edited by author 22.01.2008 17:18 With Python's dicts it's easier :) Give plz some tests Edited by author 21.10.2007 22:20 Edited by author 21.10.2007 22:20 8 8 3 4 2 4 5 4 5 3 6 1 2 1 2 3 1 5 6 1 6 7 1 7 8 1 2.00 -1.00 2.00 0.00 4.00 -3.00 4.00 -3.00 В чём ошибка не пойму.? не проходит 1 тест var i,j,k,m,s,n:integer; a,b:array[1..100000] of integer; begin read(n); k:=0; for i:=1 to n do read(a[i]); read(m); for i:=1 to m do read(b[i]); for i:=1 to n do begin for j:=1 to m do begin if a[i]+b[j]=10000 then k:=1; end; end; if k=1 then write('yes'); if k=0 then write('no'); end. Edited by author 05.02.2011 21:26 Edited by author 05.02.2011 21:30 Try to use capital letters for the answer: YES and NO Исправь "yes" и "no" на "YES" and "NO". Однако после этого будет ТЛЕ на 4 тесте. Используй быструю сортировку и бинарный поиск. Удачи! Sorting not needed because input given in sorted order. Actually you even not need to binary-search, just line scan of both arrays. Think what way summ changed if you pick next item in array. IMHO sortirovka zdes ninado |
|