Common Board| Show all threads Hide all threads Show all messages Hide all messages | | Why WA ? | sgn | 1410. Crack | 15 Oct 2009 03:05 | 2 | [code deleted] My program give right answers on all tests in this forum, but I have WA on test #2 :) Why ? :) Edited by moderator 22.02.2006 22:12 Re: Why WA ? Oleg Strekalovsky aka OSt [Vologda SPU] 15 Oct 2009 03:05 check moment in reading words, when stream is over. You may not add last word to your dictionary... And Don't pay attention to 'miamlia'.(don't find same sounds) P.S. : It's strange, that in that language lowercase letters and Uppercase letters creates different sounds (A!=a) Edited by author 16.10.2009 01:19 | | Crash (stack overflow) 1 O_O | Tbilisi SU: Gio (Away) | 1715. Another Ball Killer | 13 Oct 2009 18:49 | 9 | I wrote solution, it works well on my PC, but gives stack overflow 1 on Online judge, first test is example from problem statement, I've no idea, on Visual c++ 2008 my solution does not give any error, please help if you know whats up with Compiler on Timus... --- CODE DELETED Edited by author 13.10.2009 18:32 I think you shouldn't post whole code here. I dont think so ) anyway It is not an AC code and I can put it here. I'll delete code when I will get AC Edited by author 11.10.2009 23:44 found mistake at last :| AC now sz[++nom] = dfs(i , j , nom); this fragment changed to: nom++ sz[nom] = dfs(i , j , nom); do you see any difference? timus compiler sees :) You should study Timus C++ compiler better or write compiler-independent codes ;) Edited by author 13.10.2009 18:36 ... Edited by author 13.10.2009 18:36 ... Edited by author 13.10.2009 18:36 ... Edited by author 13.10.2009 18:35 You should study Timus C++ compiler better or write compiler-independent codes ;) Edited by author 13.10.2009 18:36 I studied that ++x increases x, before making operations on it :) PS. why all the strange things happens with me? :( I lost 1 year of my life debugging my code... :S | | ..I am O(n^2) too and got AC.. | grayluck | 1069. Prufer Code | 13 Oct 2009 15:09 | 1 | I use a very simple algorithm..my code is very short.. *just (for i:=1 to n do)check if the number appears in the A set of numbers after i. *set down the father of each number. *Just output. (i'm sorry that my English is really bad..) var con,temp,i,j:longint; fin:array[1..7500]of boolean; b,a,fa:array[1..7500]of integer; begin {$IFNDEF ONLINE_JUDGE} assign(input,'input.in');reset(input); assign(output,'output.out');rewritE(output); {$ENDIF} reaD(temp); con:=0; while temp<>0 do begin inc(con); a[con]:=temp; inc(b[temp]); read(temp); end; for i := 1 to con do for j := 1 to con+1 do if (not fin[j])and(b[j]=0) then begin fin[j]:=true; fa[j]:=a[i]; deC(b[a[i]]); break; end; for i := 1 to con+1 do begin write(i,':'); for j := 1 to con+1 do if (fa[j]=i)or(fa[i]=j) then write(' ',j); writeln; end; end. Edited by author 13.10.2009 15:09 | | How do you get 0.001? | test2008 | 1000. A+B Problem | 13 Oct 2009 15:08 | 5 | I don't understand, how it is possible... The simplest solution works for 0.015 sec. How do you read and write? scanf("%d%d", &a, &b); printf("%d\n", a + b); and streamed input doesn't give any increase in speed Edited by author 30.10.2008 01:59 Can you explain me how to read and write for 0.001 sec? Do you use buffer input? Probably 15 ms is a minimum tick of OS (mb Windows). Thus the program #include <windows.h> #include <stdio.h> int main() { Sleep(0); return EXIT_SUCCESS; } will work 15 ms while it will be not replaced by any another (as a result of actions of the dispatcher). Including the program for measurement of execution time. Someone can bypass this restriction. Edited by author 13.10.2009 15:13 | | Why I have got WA14 | bilol | 1644. A Whole Lot of Walnuts | 13 Oct 2009 07:33 | 2 | I have got wa 14 and don't know why Edited by author 29.12.2008 18:33 Bilol, Well, its almost a year now, but will write it down anyway. My WA program program was generating this: Input 5 3 hungry 4 hungry 5 hungry 5 satisfied 6 hungry Output 5 But the correct answer is Inconsistent. So, try to find maximum hungry value and minimum satisfied value and apply the given conditions. Varun | | Advice for who WA#7or#8 给WA7|WA8的建议 | grayluck | 1078. Segments | 13 Oct 2009 06:42 | 1 | (On^2)use: f[j-1]<=b[i] {means that (a=2,b=3)and(a=3,b=3) are contain too} 是最长不下降(不是上升)子序列..记得判断上个的a个当前a是否不同。 | | Why answer for G: 92? | Programmer | 1715. Another Ball Killer | 13 Oct 2009 04:55 | 2 | Why answer for G: 92? Why it is not 4*3+3*2+9*8=90? I understand, where i was wrong. | | Clarification | Alast Tiro | 1719. Kill the Shaitan-Boss | 12 Oct 2009 02:25 | 1 | Shaitan-pipe kill ALL bosses on the line. If you have WA#6 try this test: 100 0 -100 0 0 1000 0 100 Correct answer is not 100.0000000000 | | To admins: Incorrect handling Java exceptions thrown by another thread | I&K | | 11 Oct 2009 21:41 | 3 | The testing system doesn't treat exceptions thrown by a thread another than "main" as exceptions and does checking of correctness of the output after such exceptions. For example, if I write my main method in such way: new Thread() { public void run() { new Main().run(); } }.start(); and the first operator in "run" is if (true) throw new RuntimeException(); I'll get WA 1, not Crash 1. It seems to be very strange, because such uncaught exceptions is really thrown by jvm and it terminates abnormally and prints a stack trace. This behaviour of the testing system is very nagging because it hides things that really happen in the program. I never used this method, but if I wanna throw an exception - i wrote if (condition){ throw new Error(); } In this case if condition will be true you got Crash No, in this case you also will not get Crash, if this code is executed in not main thread. Otherwise, my code if (true) throw new RuntimeException(); would get Crash too. The problem is that this code is executed in the method run which in turn is executed in another thread, and the only code which is executed in main thread is new Thread() { public void run() { new Main().run(); } }.start(); For JDK 1.6 it is not necessary to create new threads, but in JDK 1.5 one can not use normal stack size in the main thread because it is determined by OS as for ordinary new thread. Despite the fact that the testing system is already using JDK 1.6, I think this issue should be fixed. After all, I didn't get AC in the last contest just because I got WA and in the last 5 minutes tried to find a bug in the logic of the program, but didn't check array sizes:( | | WA 19 HELP! | NickSergeev[MSU MindCraft] | 1720. Summit Online Judge | 11 Oct 2009 21:12 | 2 | WA 19 HELP! NickSergeev[MSU MindCraft] 10 Oct 2009 18:02 Use these functions for debugging int f(int x,int y,int z) { int i; if (z==0) return 1; for (i=x;i<=y;i++) { if (i>z) break; if (f(x,y,z-i)==1) return 1; } return 0; } int ff(int x,int y,int l,int r) { int z=0; for (int k=l;k<=r;k++) z+=f(x,y,k); return z; } also: to verivy k*x>a for big numbers is better to use: k>=floor(a/x) if a%x!=0 k>a/x if a%x==0 because k*x can generate overflow I got Ac after using all attention to boundary values 10^18. Edited by author 11.10.2009 21:19 | | To admins: threads | icanwin | | 11 Oct 2009 18:29 | 2 | There is an injustice: coders on Java have possibility to create threads, and coders on C/C ++ have no such possibility. It is necessary to give the possibility to include <pthreads.h> or <windows.h>. | | To admins: binary_function<member, member, bool> | VorobeY1326 | | 11 Oct 2009 14:17 | 1 | Hello! I have tryed to solve 1022 on C++: #include<iostream> #include<vector> #include<algorithm> using namespace std; struct member { int latency; int number; vector<int>child; member() {latency=0; child.resize(0);} }; struct member_less : public binary_function<member, member, bool> { bool operator()(const member& m1, const member& m2) const { return m1.latency < m2.latency; }; }; int main() { int numb_of_members; cin >> numb_of_members; vector<member>mosk(numb_of_members); for (int i=0;i<numb_of_members;i++) { mosk[i].number=i; int buf; cin >> buf; while(buf!=0) { mosk[i].child.push_back(buf); cin >> buf; } } bool stop=false; while(stop==false) { stop=true; for (int i=0;i<numb_of_members;i++) { for(int j=0;j<mosk[i].child.size();j++) { if (mosk[mosk[i].child[j]].latency <= mosk[i].latency) {mosk[mosk[i].child[j]].latency = mosk[i].latency+1; stop=false;} } } } sort(mosk.begin(),mosk.end(),member_less()); for (int i=0;i<numb_of_members;i++) cout << mosk[i].number << " "; return 0; } But I have got errors: 685a5f5c-5454-4df3-be25-6c467c9fdfd1 685a5f5c-5454-4df3-be25-6c467c9fdfd1(14): error: binary_function is not a template struct member_less : public binary_function<member, member, bool> ^ 685a5f5c-5454-4df3-be25-6c467c9fdfd1(14): error: not a class or struct name struct member_less : public binary_function<member, member, bool> Why? On my computer this programm works well! | | Problem K | Hemant Verma | | 10 Oct 2009 20:00 | 4 | Hi, I thought of bipartite matching as possible solution , can any one tell me what is the correct algorithm to solve this problem. Here is my code #define _CRT_SECURE_NO_WARNINGS #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <cstdio> #include <cassert> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; int inf=(1<<28); double eps=1e-9; double pi=acos(-1.0); typedef vector<int> vi; typedef long long int64; typedef pair<int,int> ii; #define size(x) (int)((x).size()) #define all(v) (v).begin(), (v).end() #define For(i,x) for(int i=0;i<x;i++) #define Forr(i,y,x) for(int i=y;i>=x;i--) #define Forn(i,y,x) for(int i=y;i<=x;i++) #define Fill(a, v) memset(a, v, sizeof(a)) #define outs(x) cout << #x << " = " << x << " "; #define outn(x) cout << #x << " = " << x << "\n"; int n; int prev[1001]; vi graph[1001]; int visit[1001]; int rank[1001]; string name[1001]; string ans[501][2]; int speciality[1001]; bool findNext(int x) { if(x<0)return true; if(visit[x])return false; visit[x]=1; int sz = size(graph[x]); For(i,sz) { int y = graph[x][i]; if(findNext(prev[y])) { prev[y]=x; //prev[x]=y; return true; } }
return false; } int main() { #ifdef FAMEOFLIGHT_HOME freopen("input.txt","r",stdin);freopen("output.txt","w",stdout); // freopen("input2.txt","r",stdin);freopen("output2.txt","w",stdout); #endif int tmp; char str1[30],str2[30]; scanf ("%d",&n); For(i,n) { scanf ("%s %s %d",&str1,&str2,&tmp); rank[i]=tmp; name[i]=string(str1); if(str2[0]=='a')speciality[i]=0; if(str2[0]=='s')speciality[i]=1; if(str2[0]=='t')speciality[i]=2; } // construct the graph For(i,n) { For(j,n) { if(abs(rank[i]-rank[j])==2) { if(speciality[i]==0 || speciality[j]==0)graph[i].push_back (j) , graph[j].push_back (i); else if((speciality[i]==1 && speciality[j]==2) || (speciality[i]==2 && speciality[j]==1))graph[i].push_back (j) , graph[j].push_back (i); } } } int ret=0; Fill(prev,-1); For(i,n) { Fill(visit,0); findNext(i); }
For(i,n) { if(prev[i]!=-1) { prev[prev[i]]=-1; int x = i , y = prev[i]; ans[ret][0]=name[x]; ans[ret++][1]=name[y]; //printf ("%s %s\n",name[x].c_str (),name[y].c_str ()); } } printf ("%d\n",ret); For(i,ret) { printf ("%s %s\n",ans[i][0].c_str (),ans[i][1].c_str ()); } return 0; } Evident- nonbipartite matching but may be more simple Still don't understand , can you give me hint because of existing of "anything" we should use nonbipartite matchig algo(Gabov, Blum and so on) T(n)=O(n^3)=10^9- rather well. | | WA#12 what is wrong this function? | xurshid_n | 1720. Summit Online Judge | 10 Oct 2009 19:50 | 1 | function calc(x, y, l ,r: int64): int64; var n, nx, ny: int64; n1,n2: int64; begin if l < x then l := x; if x > r then begin result := 0; exit; end; if ( x = 1 ) then begin result := (r - l + 1); exit; end; if x = y then begin result := ( r div x - ((l-1) div x) ); exit; end; if y + 1 >= x + x then begin result := (r - l + 1); exit; end; n := (y - 2) div ( y - x ) + 1; while (y * (n - 1) + 1 >= x * n) and (n > 0) do dec(n); if n * x <= l then begin result := (r - l + 1); exit; end; result := 0; if n*x <= r then begin result := r - n*x + 1; r:=n*x - 1; end; nx := (l + y - 1) div y; if nx*x > r then begin result := result + 0; exit; end; ny := r div x; if ny * y < l then begin result := result +0; exit; end; if ( ny * x <= l ) and (ny*y >= r)then begin result := result +r - l + 1; exit; end; if ( nx * x <= l ) and (nx*y >= r)then begin result := result +r - l + 1; exit; end; if (ny * y < l ) and ( ny * x + x > r) then begin result := result +(0); exit; end; if nx = ny then begin if l < nx * x then l := nx * x; if r > nx * y then r := ny * y; result := result +(r - l + 1); exit; end; if l < nx * x then l := nx * x; if r > nx * y then r := ny * y; n1 := nx + 1; n2 := ny - 1; if n1 <= n2 then result := result + (n2 - n1 + 1) + (y-x) * (( n1+n2) * (n2-n1+1) div 2); result := result + nx * y - l + 1 + (r - ny*x + 1);
end; | | WA case 10,help | mypal | 1720. Summit Online Judge | 10 Oct 2009 18:08 | 1 | | | help me!! WA | Mostafa_angel | 1718. Rejudge | 10 Oct 2009 17:09 | 1 | #include <iostream> #include <string> #include <algorithm> #include <map> using namespace std; int main() { int n; map <string , string> user; map <string , string > ::iterator it; string name , er , ti ; cin >> n; for(int i = 0 ; i < n ; i++) { cin >> name >> er; if(er == "CE") { it = user.find(name); if(it == user.end()) user[name] = "0"; } else if(er == "AC") { user[name] = "a"; } else { cin >> ti; it = user.find(name); if(it != user.end()) user[name] = max(ti, it->second); else user[name] = ti; } } //cout << " ^^^ " << user.size() << endl; it = user.begin(); int mx = 0 , mn = 0; while(it != user.end()) { //cout << "first == " << it->first << " second == " << it->second << endl; if(it->second == "6" || it->second == "a") mx++; if(it->second == "7") { mn++; mx++; } it++; } cout << mn << " " << mx << endl; return 0; } what the wrong !? | | Plz help me! | wcwswswws | 1718. Rejudge | 10 Oct 2009 17:07 | 1 | "The outcomes which differ only in test number are considered different."It means that the maximum number of tests passed are different? Edited by author 10.10.2009 17:16 Edited by author 10.10.2009 17:18 | | Please correct me! | Igor9669 | 1715. Another Ball Killer | 10 Oct 2009 17:04 | 4 | Folowing your algo when the Main ball is Blue we should get 82 point (8*7 + 3*2 + 1*0 + 1*0 + 5*4),but why the answer 74? why when the figure consist of one ball what should be? Sorry I find my mistake! Edited by author 10.10.2009 17:19 Edited by author 10.10.2009 17:19 | | Explain me | McArchuk | 1718. Rejudge | 10 Oct 2009 16:05 | 1 | I can not understand problem statement. Please explain me it | | WA 2 | McArchuk | 1721. Two Sides of the Same Coin | 10 Oct 2009 16:02 | 1 | WA 2 McArchuk 10 Oct 2009 16:02 I use greedy. Is this rigth? Give me some tests. |
|
|