Common BoardУ меня программа получила AC, хотя на тест 1999 выдавала ответ 1991... мне кажется, что это не совсем верно... New tests were added. Thank you. Зачем добавлять новые тесты, если по уже существующим нельзя пройти на верной программе? Edited by author 27.11.2012 23:29 Edited by author 27.11.2012 23:29 Why do you think that your program is right? I got WA on Test 16,but I don't know why. Interesting, most people hit WA2 then AC, but I skipped WA2 and jumped right to WA3, seem to be the first to hit it. Can't find the error....switched to java & BigInteger thinking numerical overflow in c++ may be the issue but still WA3. Argh. Found stupid stupid stupid mistake in boundary case handling...AC! I've read it for 15 min..AC at the first time... sort all the integer to a descending sequence. repeat for n-1 times: combine a[1] and a[2](2sqrt(xy)) delete(a[1],a[2]) insert the new real number into the sequence and remember to keep the descending. print the final a[1]. what's mean here is delete(a[1],a[2]); don't understand Hi Ayubxon, delete means "no longer worry about a[1] and a[2]". You may not actually delete the values from array. Regards Anupam 4 1 4 5 6 ans: 17 --> 1,4 4 <-- 1 1 --> 1,5 5 <-- 1 1 --> 1,6 6 17 follow is my program: var a:array[1..10000]of longint; z:array[1..10000]of integer; i,j,k,n:longint; begin fillchar(a,sizeof(a),0); fillchar(z,sizeof(z),0); read(n); for i:=1 to n do begin read(a[i],j);z[i]:=i;end; for i:=1 to n-1 do for j:=i+1 to n do if a[z[i]]>a[z[j]] then begin k:=z[i]; z[i]:=z[j]; z[j]:=k; end; i:=0; while i<n do begin writeln(z[i+1],' ',z[i+2]); inc(i,2); end; end. Try this: 4 1 1 1 3 1 2 1 4 Your program says 1 2 3 4 but those roads intersect. My first solution was wrong also, but I sort towns by polar angle and I can choose center randomly. TO JUDGES: Can you add few tests that catch solutions, which sort towns only by X or by Y? I think this is incorrect test. Because, No three towns lay on one line. Your solution looks so strange! Can you tell me why it works? Oh, you needn't explain it to me any more. I have understood it! Ha! Very funny! I got it! Oh, yeah!!!!!!!!!!!!! bravoooo!!! Your idea is very good. My code... #include <iostream> #include <string> using namespace std; struct LAN { int somay; char **IP; char **Sub; }; int ChungMang(int a, int b, LAN *L); void Dijkstra(LAN *L, int d[], int prev[], int label[], int dau, int cuoi, int somang,int &kq); void Show(int dau, int cuoi, int prev[]); void main () { int somang; cin>>somang; LAN *L; L= new LAN[somang+1]; for(int i =1;i<=somang;i++) { cin>>L[i].somay; L[i].IP=new char*[L[i].somay]; L[i].Sub=new char*[L[i].somay]; for(int j = 0;j<L[i].somay;j++) { L[i].IP[j]=new char[100]; L[i].Sub[j]=new char[100]; cin>>L[i].IP[j]>>L[i].Sub[j]; } } int dau, cuoi; cin>>dau>>cuoi; int d[91]; int prev[91]; int label[91]; int kq=1; Dijkstra(L,d,prev,label,dau,cuoi,somang,kq); if(kq==0) return; cout<<"Yes\n"; Show(dau,cuoi,prev); } void Init(int d[], int prev[], int label[], int n, int dau) { for(int i=1; i<=n;i++) { d[i]=-1; prev[i]=-2; label[i]=1; } d[dau]=0; } void Dijkstra(LAN *L, int d[], int prev[], int label[], int dau, int cuoi, int somang,int &kq) { Init(d,prev,label,somang,dau); while(label[cuoi]==1) { int iMin = -1; int v = -1; for(int i=1;i<=somang;i++) { if(label[i]==1 && d[i]!=-1&&(d[i]<iMin||iMin==-1)) { iMin = d[i]; v=i; } } if(iMin == -1) { cout<<"No"; kq =0; break; } d[v]=iMin; label[v]=0; for(int j=1;j<=somang;j++) { if(label[j]==1&& ChungMang(v,j,L)==1) { d[j]=d[v]+1; prev[j]=v; } } } } int Test(char *IP3, char *IP4, char *Sub3, char *Sub4) { char *IP1 = IP3; char *IP2=IP4; char *Sub1= Sub3; char *Sub2=Sub4; int i=0; int nIP=0; int nSub=0; while(nIP!=3) { if(IP1[i]=='.') nIP++; i++; } nIP=i; i=0; while(nSub!=3) { if(Sub1[i]=='.') nSub++; i++; } nSub=i; IP1[nIP]='\0'; IP2[nIP]='\0'; Sub1[nSub]='\0'; Sub2[nSub]='\0'; if(strcmp(IP1,IP2)==0&&strcmp(Sub1,Sub2)==0) return 1; return 0; } int ChungMang(int a, int b, LAN *L) { int giong=0; for(int i=0;i<L[a].somay;i++) { for(int j = 0;j<L[b].somay;j++) { if(Test(L[a].IP[i],L[b].IP[j],L[a].Sub[i],L[b].Sub[j])) return 1; } } return 0; } void Show(int dau, int cuoi, int prev[]) { int temp[100]; int i=99; int k = cuoi; cout<<dau; while (k != dau) { temp[i]=k; k=prev[k]; i--; } for(int j = i+1;j<100;j++) {
cout<<" "<<temp[j]; cout<<endl; } } this kind of problems are easy,, i guess they exist to build up your confidence. xD then check carefully your solution for n=3 :) i found my mistake :) Edited by author 15.10.2012 19:23 Edited by author 15.10.2012 19:23 Hey, man! I have wa#2. Please, tell me, what was your mistake in this case? What is wrong with my code? I can't figure out by myself:( Some people talking about some tricky case. What is it? Check your code for the extreme cases. -1000 -1000 -1000 1000 1000 1000 0 0 0 0 I've found that sqrt returns NaN for values below 1e-8 (approximately). Your test is incorrect, because R must be a positive integer. > I've found that sqrt returns NaN for values below 1e-8 (approximately). I cannot know what compiler you use, but in my GCC (and judge's MSVC) there is several functions for finding a square root: ___ float sqrtf(float); ___ double sqrt(double); ___ long double sqrtl(long double); and the last two compute a proper value for 1e-8. Edited by author 28.07.2011 02:49 Well, I solved a mysterious case of WA #8. :-) Just checked every double variable whether it is NaN. I had a working program, but get WA only because of acos function. When I had started to use something like this instead of acos: > double arccos(double x) { > x = min(1.0d, max(-1.0d, x)); > return acos(x); > } I got AC. Hi. Can you explain me, why this function of arccos is working correctly?) Because our program does not accepted without it. I dont know if I use the array with size 131072 I get result "access violation" if I use the size 131073 I get the result "stack overflow" so how I get the right way to resolve the problem, sorry for my bad english; #include <stdio.h> #include <math.h> int main() { int index = -1; double stack[131073]; while(scanf("%lf", &stack[++index]) != EOF); for(; top > 0;printf("%.4lf\n", sqrt(stack[--index]))); return 0; } #include <stdio.h> #include <math.h> double stack[131073]; int main() { int index = -1; while(scanf("%lf", &stack[++index]) != EOF); for(; index > 0;printf("%.4lf\n", sqrt(stack[--index]))); return 0; } Did you resolve the problem? Edited by author 07.12.2012 09:36 Problem is here : floor(x+0.5); You are not saving result of this function :) Why this contest is absent in archive of competitions: http://acm.timus.ru/monitor.aspx?id=61? And why I was disqualified from it? I am very advanced mathematician so why the fact that I solved problems A and B during the contest so bothered admins? It's complete lawlessness :( Maybe you use recursion fill field? N=12 Q=26 not 34. 34 or 26 But 26 is less than 34 Edited by author 24.11.2012 23:51 My solutions is stack overflow in test 9. Help me, please. Could anyone give me the test#6? godsuriyel@gmail.com thanks! please!!! кто знает тест 2????? It helped me: 5 4 2 2 1 1 1 answer: 5 2 5 7 4 1 4 1 2 answer: 3 1 EDITED - NEVER mind - I think I understand Edited by author 07.11.2012 09:58 Edited by author 07.11.2012 09:58 why ans is 3 1 ? Becase 1 spell of strength 2 eliminates 3 coins (1, 1, 2) The (4,4) can never be eliminated because it causes a bounce back of 8, and 7 is the survival limit I want some tips or tests |
|