WA 15: "Teams are as close in their sizes as possible." It doesn't mean that the size of one of the commands must be exactly n//2. Wa 25: "Every team has at least one member" Edited by author 15.10.2024 20:07 Sorry, the test is not small. Now I will give a description of the test. There 5 groups with sizes: (6 1) (5 1) (4 1) (4 1) (4 1). The right answer for this test is 14:14. But the greedy program gives 15:13. I think moderators shall add this test to the test data and many solutions will be rejected. 28 21 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 0 26 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 0 26 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 0 26 2 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 0 26 2 3 4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 0 26 2 3 4 5 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 0 26 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 0 22 1 2 3 4 5 6 7 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 0 26 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 0 26 1 2 3 4 5 6 7 9 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 0 26 1 2 3 4 5 6 7 9 10 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 0 26 1 2 3 4 5 6 7 9 10 11 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 0 26 1 2 3 4 5 6 7 9 10 11 12 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 0 23 1 2 3 4 5 6 7 8 9 10 11 12 13 19 20 21 22 23 24 25 26 27 28 0 26 1 2 3 4 5 6 7 8 9 10 11 12 13 16 17 18 19 20 21 22 23 24 25 26 27 28 0 26 1 2 3 4 5 6 7 8 9 10 11 12 13 15 17 18 19 20 21 22 23 24 25 26 27 28 0 26 1 2 3 4 5 6 7 8 9 10 11 12 13 15 16 18 19 20 21 22 23 24 25 26 27 28 0 26 1 2 3 4 5 6 7 8 9 10 11 12 13 15 16 17 19 20 21 22 23 24 25 26 27 28 0 23 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 24 25 26 27 28 0 26 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 21 22 23 24 25 26 27 28 0 26 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 20 22 23 24 25 26 27 28 0 26 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 20 21 23 24 25 26 27 28 0 26 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 20 21 22 24 25 26 27 28 0 23 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 0 26 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 26 27 28 0 26 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 25 27 28 0 26 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 25 26 28 0 26 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 25 26 27 0 up Do judges want to break greedy wrong solutions? Or it is OK that they are accepted? It is strange, that NEERC problem has poor set of tests. DO NOT MISLEAD OTHERS WITH YOUR WRONG SAMPLE!!! MY AC program says NO SOLUTION! take care of the following nodes 1st group: 1 8 14 19 24! 26 2nd group: 2 3 4 5 6 7 9 10 11 12 13 15 16 17 18 20 21 22 23 24! 25 27 28 when you start deducting from 24 to other non connected with 24 nodes and so on, you will get a contradiction. My AC prog says 14 24 19 14 9 10 11 12 13 2 3 4 5 6 7 14 1 8 15 16 17 18 20 21 22 23 25 26 27 28 can anyone send me a test please? semenanufriev@gmail.com do anyone knows the 25th test? I think my alg is correct but I can't acc it... help pls! Do a dfs on G complement to make it a set of bipartite graphs (remove one way edges) then brute force on set of components after some optimization to avoid TLE and find the best dividing... any idea?! Edited by author 20.08.2015 17:30 Hi all. I use dfs to find the number of connected components. If there are 2 components,then i output each of them as a single team.If there is only 1 CC,then i output numbers from 1 to n/2 and from n/2+1 to n. Otherwise "No solution". It seems to me correct,but.... Or tell me some tests that prove my idea's fail) Your idea is incorrect. 1) If 1st person knows 2nd person it doesn't mean that 2nd person knows 1st person. 2) If 1st and 2nd persons know each other and 1st and 3rd persons also know each other it doesn't mean that 2nd person knows 3rd person and vice versa. According to your algo in the first case both persons will be in one connected component, and in the second case all 3 persons will be in one connected component. Hi, I think that you should find the strongest connected components in a digraph. Can somebody share test case #5? And,shouldn't this problem have a special judge?There may be many situations. __ var col:array[1..100] of longint; c,c1,map:array[0..100,0..100] of boolean; t:array[1..3,1..100] of boolean; a,a1:array[0..100] of boolean; sum:array[0..3] of longint; n,i,j,k,l,x,ans:longint;
procedure dfs(x,v:longint); var i:longint; begin if col[x]<>0 then exit; if col[x]+v=3 then begin writeln('No solution');halt;end; col[x]:=v;inc(sum[v]);t[v,x]:=true; for i:=1 to n do if x<>i then if map[x,i] and map[i,x] then dfs(i,3-v); end; begin assign(input,'1.txt');reset(input); readln(n);fillchar(col,sizeof(col),0);a[0]:=true; for i:=1 to n do begin read(x);while x<>0 do begin map[i,x]:=true;read(x);end;end; for i:=1 to n do if col[i]=0 then begin fillchar(t,sizeof(t),0);sum[1]:=0;sum[2]:=0;dfs(i,1); fillchar(a1,sizeof(a1),0); for k:=1 to 2 do for j:=0 to n-sum[k] do if a[j] and not a1[j+sum[k]] then begin a1[j+sum[k]]:=true; for l:=1 to n do c1[j+sum[k],l]:=c[j,l] or t[k,l]; end;a:=a1;c:=c1; end;ans:=n;while(not a[ans])and(ans>=1) do dec(ans); write(ans);for i:=1 to n do if c[ans,i] then write(' ',i);writeln; write(n-ans);for i:=1 to n do if not c[ans,i] then write(' ',i);writeln; end.
sim_pet3@hotmail.com Thank you very much ^^ I have WA on the test 25. Who can help me? I have the tests. If you want them , post your mail adress. This is mine: charles8827@163.com Thank you very much. Gheorghe Stefan I got WA on test 15.. Please post the tests to me. Thank you very much. My e-mail : happy123456@hotmail.com Edited by author 18.05.2004 16:47 I find the tests. And I find my mistake. I got AC . :) Edited by author 18.05.2004 16:57 Here is my e-mail:sanguokuang@yahoo.com.cn Please send me the tests.Thenk you! Please give me the tests. My e-mail : alexpopa@shock.ldc.ro I found the tests on the web, I tested my program an it shows the correct answers. Can anybody help me ? Could anyone tell me where I can get the tests?Thank you. My program passes all tests from NEERC, but has WA18 on Timus. I can't find my mistake. :( I Wa on Test 25, I need the Tests. Could you send it to me? Thank you. My E-mail: Skyfish_cdq@hotmail.com I have the tests. If you want them , post your mail adress. I Wa on Test 25. Could you send it to me? Thank you. alvinhuang1105@163.com Just google "NEERC 2001"... My Email:sxcyd@126.com Thank you! Edited by author 23.10.2010 08:26 OX-OX-OX You can send to me your code. naxart@yandex.ru Thank you!! But I Already found my mistake. Who has WA 43 Try 6 2 3 4 5 0 1 3 6 0 1 2 4 5 0 1 3 5 6 0 1 3 4 6 0 2 4 5 0 output must be 3 1 2 3 3 4 5 6 You must use ALL people. Don't miss them while filling dp to find optimal partition. The Judge's Server is powerful.. i uses DFS and DP to kill it. But a simple wrong let me not 1Y this prolem.. Edited by author 07.02.2009 22:02 Logic & DP & Theory graphs & Attentiviness = AC Thanks huge to authors of this problem! Yeah. Bruteforce O(exp) + BFS - any DP = AC in 0.015 :D Yes,they're nearly the same Edited by author 18.07.2004 00:58 I even used sources from 1156 with changed input :) WA On Test #16 #include <stdio.h> #include <memory.h> #include <stdlib.h> #define max(a, b) (a) > (b) ? (a) : (b) bool link[101][101]; int n; int main(void){ memset(link, false, sizeof(link));
scanf("%d", &n); for (int i = 1; i <= n; i++){ int next; scanf("%d", &next); while (next != 0){ link[i][next] = true; scanf("%d", &next); } }
for (int i = 1; i <= n; i++){ for (int j = i + 1; j <= n; j++){ if (!link[i][j] || !link[j][i]){ link[i][j] = link[j][i] = true; } else { link[i][j] = link[j][i] = false; } } }
bool vis[101]; memset(vis, false, sizeof(vis)); int blocks[101][101][2], blocks_size[101][2], blocks_count = -1; for (int i = 1; i <= n; i++){ for (int j = i + 1; j <= n; j++){ //??????????? if (link[i][j] && !vis[i]){ int queue[2][101], queue_size[2], head[2]; queue_size[0] = queue_size[1] = 0; head[0] = head[1] = 0; queue[1][0] = i; vis[i] = true; queue[0][0] = j; vis[j] = true; while (head[0] <= queue_size[0] || head[1] <= queue_size[1]){ if (head[0] <= queue_size[0]){ int point = queue[0][head[0]]; for (int k = 1; k <= n; k++){ if (link[point][k] && !vis[k]){ queue[1][++queue_size[1]] = k; vis[k] = true; } } head[0]++; }
if (head[1] <= queue_size[1]){ int point = queue[1][head[1]]; for (int k = 1; k <= n; k++){ if (link[point][k] && !vis[k]){ queue[0][++queue_size[0]] = k; vis[k] = true; } } head[1]++; } }
for (int k = 0; k <= queue_size[0]; k++){ for (int l = k + 1; l <= queue_size[0]; l++){ if (link[queue[0][k]][queue[0][l]]){ printf("No solution\n"); getchar(); getchar(); getchar(); getchar(); return 0; } } }
for (int k = 0; k <= queue_size[1]; k++){ for (int l = k + 1; l <= queue_size[1]; l++){ if (link[queue[1][k]][queue[1][l]]){ printf("No solution\n"); getchar(); getchar(); getchar(); getchar(); return 0; } } }
blocks_count++; blocks_size[blocks_count][0] = queue_size[0]; blocks_size[blocks_count][1] = queue_size[1]; for (int k = 0; k <= queue_size[0]; k++) blocks[blocks_count][k][0] = queue[0][k]; for (int k = 0; k <= queue_size[1]; k++) blocks[blocks_count][k][1] = queue[1][k]; } } }
for (int i = 1; i <= n; i++){ if (!vis[i]){ blocks_count++; blocks_size[blocks_count][0] = 0; blocks_size[blocks_count][1] = -1; blocks[blocks_count][0][0] = i; vis[i] = true; } }
bool status[101], status_x[101]; bool way[101][101], way_x[101][101]; memset(way, false, sizeof(way)); memset(status, false, sizeof(status)); status[0] = true; for (int i = 0; i <= blocks_count; i++){ memset(way_x, false, sizeof(way_x)); memset(status_x, false, sizeof(status_x)); for (int j = 0; j <= n / 2; j++){ if (status[j]){ if (!status_x[j + blocks_size[i][0] + 1] && j + blocks_size[i][0] + 1 <= n / 2){ status_x[j + blocks_size[i][0] + 1] = true; memcpy(way_x[j + blocks_size[i][0] + 1], way[j], sizeof(way_x[j + blocks_size[i][0] + 1])); for (int k = 0; k <= blocks_size[i][0]; k++){ way_x[j + blocks_size[i][0] + 1][blocks[i][k][0]] = true; } }
if (!status_x[j + blocks_size[i][1] + 1] && j + blocks_size[i][1] + 1 <= n / 2){ status_x[j + blocks_size[i][1] + 1] = true; memcpy(way_x[j + blocks_size[i][1] + 1], way[j], sizeof(way_x[j + blocks_size[i][1] + 1])); for (int k = 0; k <= blocks_size[k][1]; k++){ way_x[j + blocks_size[i][1] + 1][blocks[i][k][1]] = true; } } } } memcpy(way, way_x, sizeof(way_x)); memcpy(status, status_x, sizeof(status_x)); }
for (int i = n / 2; i >= 1; i--){ if (status[i]){ printf("%d", i); for (int j = 1; j <= n; j++){ if (way[i][j]) printf(" %d", j); }
printf("\n%d", n - i); for (int j = 1; j <= n; j++){ if (!way[i][j]) printf(" %d", j); } }
break; }
getchar(); getchar(); getchar(); getchar(); } Sorry, I've made some silly mistakes. I'll try to do better next time. Thanks! i got wrong ans #25 .Please send me tests. thanks. my ym : linhduong55@yahoo.com type anstype = array[0..100] of longint; var l : longint; n : longint; f : array[1..100, -100..200] of boolean; ans : array[1..2] of anstype; go : array[1..100, 0..100] of longint; save : array[1..100, 0..100] of longint; g : array[1..100, 0..100] of longint; done : array[1..100] of boolean; list : array[1..100, 1..2] of anstype; que : array[1..100] of longint; edge : array[1..100, 1..100] of boolean; procedure init; var have : boolean; i, j, a, k : longint; hash : array[0..100] of boolean; begin readln(n); fillchar(g, sizeof(g), 0); for i := 1 to n do begin fillchar(hash, sizeof(hash), false); repeat read(a); hash[a] := true; until a = 0; for j := 1 to n do if (not hash[j]) and (i <> j) then begin have := false; for k := 1 to g[i, 0] do if g[i, k] = j then begin have := true; break; end; if not have then begin inc(g[i, 0]); g[i, g[i, 0]] := j; end; have := false; for k := 1 to g[j, 0] do if g[j, k] = i then begin have := true; break; end; if not have then begin inc(g[j, 0]); g[j, g[j, 0]] := i; end; end; end; fillchar(edge, sizeof(edge), false); for i := 1 to n do for j := 1 to g[i, 0] do edge[i, g[i, j]] := true; end; procedure get_tree(start : longint); var now : array[1..100] of longint; get_in : array[1..100] of boolean; level : longint; i, h, t, k, j : longint; begin que[1] := start; h := 1; t := 1; now[1] := 1; fillchar(get_in, sizeof(get_in), false); get_in[start] := true; while true do begin k := que[h]; level := now[h]; done[k] := true; for i := 1 to g[k, 0] do begin if get_in[g[k, i]] then continue; inc(t); que[t] := g[k, i]; get_in[g[k, i]] := true; now[t] := level + 1; end; inc(list[l, level mod 2 + 1, 0]); k := list[l, level mod 2 + 1, 0]; list[l, level mod 2 + 1, k] := que[h]; inc(h); if h > t then break; end; for k := 1 to 2 do for i := 1 to list[l, k, 0] do for j := i + 1 to list[l, k, 0] do if edge[list[l, k, i], list[l, k, j]] then begin writeln('No solution'); halt; end; end; procedure make; var i : longint; begin l := 0; fillchar(done, sizeof(done), false); for i := 1 to n do if not done[i] then begin inc(l); get_tree(i); end; end; procedure dp; var tmp : anstype; i, t, j : longint; begin fillchar(f, sizeof(f), false); f[1, abs(list[1, 1, 0] - list[1, 2, 0])] := true; for i := 2 to l do begin t := abs(list[i, 1, 0] - list[i, 2, 0]); for j := 0 to 100 do begin f[i, j] := f[i - 1, j - t] or f[i - 1, j + t]; if not f[i, j] then continue; if (f[i - 1, j - t]) then begin save[i, j] := j - t; go[i, j] := 2 end else begin save[i, j] := j + t; go[i, j] := 1; end end; end; for i := 1 to l do if list[i, 1, 0] < list[i, 2, 0] then begin tmp := list[i, 1]; list[i, 1] := list[i, 2]; list[i, 2] := tmp; end; end; procedure add(a, b, c : longint); var tmp : anstype; i : longint; begin for i := 1 to list[b, c, 0] do ans[a, ans[a, 0] + i] := list[b, c, i]; inc(ans[a, 0], list[b, c, 0]); if ans[1, 0] < ans[2, 0] then begin tmp := ans[1]; ans[1] := ans[2]; ans[2] := tmp; end; end; procedure out(x, y : longint); var tmp : anstype; i, t : longint; begin if x = 1 then begin add(1, x, 1); add(2, x, 2); exit; end; out(x - 1, save[x, y]); if go[x, y] = 1 then begin add(1, x, 2); add(2, x, 1); end else begin add(1, x, 1); add(2, x, 2); end; end; procedure print; var i, j, t : longint; begin fillchar(ans, sizeof(ans), 0); for i := 0 to 100 do if f[l, i] then break; out(l, i); for t := 1 to 2 do begin write(ans[t, 0]); for i := 1 to ans[t, 0] do write(' ', ans[t, i]); writeln; end; end; begin init; make; dp; print; end. Edited by author 15.08.2005 10:50 I can't get accepted. I found tests from ACM contest for this problem and my program works good on them. I think 56 tests is enough to confirm corectness of my solution, but I still get Wrong Answer! Can anyone help me? Can you give me your test ??? My e-mail: manhhungpham2631988@yahoo. Can you give me your tests ??? My e-mail: manhhungpham2631988@yahoo.com Can you give me your tests ??? My e-mail: manhhungpham2631988@yahoo.com Send me your code, I will check it for you:) |
|