Общий форум Edited by author 11.02.2013 22:27 Edited by author 11.02.2013 22:27 There are wrote Runtime error (access violation), and number of test 1. What's that meen? Sorry if I wrong! But I'm not exactly understand, what in this code is Wrong!? Fist test I suppose is 5 3,6 7 2 and 5 3,20 0 0 and my programm show's 0 and 5, exactly like in example. Beforehand Thank's and ne "obisuyte" for my english!-) I used long arithmetics and calculated "36*pow(55,k-1);". But I have WA5. Please, say why or give that test... Maybe you write wrong long arithmetics. I think you forgot leading zeroes. I had the same mistake. Use this test: 9 3014421764062500 Sorry for my poor English. What's this test? Edited by author 28.10.2012 13:07 Try this test: 5 1 1 1 1 1 Answer is 1 5 1 2 3 4 5 Numbers order in the last(after 5) doesn't metter but if we add to team 1 2 3 4 hero#5 this team will be effective? All teams that satisfy each member's demands are effective, the key to this problem is understanding the definition of "reliable." It took me several readings of the problem statement to get this clear. Excuse me. I can't understand you. Can you answer my question? in test 5 1 1 1 1 1 team with heroes 1, 2, 3 and 4 is reliable? It appears the wording for the problem has changed. This was a badly worded problem to begin with, but now it is *incorrectly* worded! The original wording was something like: "an effective team is also reliable if there exists no superhero such that adding the superhero to the team results in an effective team." Basically, a "reliable" team is one that cannot be added on to (by exactly one superhero) to make another effective team. So no, in the case "5 / 1 / 1 / 1 / 1 / 1" , "1 2 3 4" is not reliable because there exists a superhero such that adding it on to the team makes another effective team. Edited by author 31.10.2012 03:05 Thank you very much! On this test: 5 1 1 1 1 1 My program gets Answer is 1 5 1 2 3 4 5 but I am still getting WA7. yet have any thoughts on this? What's wrong? var n,p,k,i:longint; m:array [1..65535] of longint; begin readln(n); p:=1; k:=0; for i:=1 to n do readln(m[i]); for i:=1 to n do begin while m[i]>p do begin p:=p+k; k:=k+1; end; if p=m[i] then write(1,' ') else write(0,' '); p:=1; k:=0; end; end. you shold use maths method, maths formula #include <stdio.h> #define MaxN 100000+252 #define MaxPop MaxN/2+1 struct pointer { int s; char o; }; struct pointer GetPointer(int i) { struct pointer p; p.s=i/250; p.o=i % 250; return p;
} struct Stack { int V; struct pointer pred; }; int GetAdress(struct pointer p) { return p.s*250+p.o; } int A[1001]; int MP; struct Stack B[MaxN]; int Pop(int S) { int E; E=B[A[S]].V; A[S]=GetAdress(B[A[S]].pred); return E; } int Push(int S, int E) { int i=A[S]; MP++; B[MP].V=E; B[MP].pred=GetPointer(i); A[S]=MP; return 0; } int main() {
int N,i,j,E,k; int S; char command[10]; scanf("%d",&N);
MP=0; B[MP].V=0; B[MP].pred=GetPointer(0); for (i=1;i<1000;i++) A[i]=0; k=0; for (i=1;i<=N;i++) {
scanf("%s",command); if (command[1] == 'U'){ scanf("%d %d",&S,&E); Push(S,E); } else { scanf("%d",&S); k++; printf("%d\n",Pop(S)); } }
return 0; } Here is my code #include <stdio.h> #define MaxN 100000+252 #define MaxPop MaxN/2+1 struct pointer { int s; char o; }; struct pointer GetPointer(int i) { struct pointer p; p.s=i/250; p.o=i % 250; return p;
} struct Stack { int V; struct pointer pred; }; int GetAdress(struct pointer p) { return p.s*250+p.o; } int A[1001]; int MP; struct Stack B[MaxN]; int Pop(int S) { int E; E=B[A[S]].V; A[S]=GetAdress(B[A[S]].pred); return E; } int Push(int S, int E) { int i=A[S]; MP++; B[MP].V=E; B[MP].pred=GetPointer(i); A[S]=MP; return 0; } int main() {
int N,i,j,E,k; int S; char command[10]; scanf("%d",&N);
MP=0; B[MP].V=0; B[MP].pred=GetPointer(0); for (i=1;i<1000;i++) A[i]=0; k=0; for (i=1;i<=N;i++) {
scanf("%s",command); if (command[1] == 'U'){ scanf("%d %d",&S,&E); Push(S,E); } else { scanf("%d",&S); k++; printf("%d\n",Pop(S)); } }
return 0; } Edited by author 10.02.2013 18:10 What is test 6? I am stuck at it for a very long time! What is the true way to change k-(needed numbers) http://pastebin.com/f27Pt0HC - code #include <iostream>; #include <map>; #include <string>; using namespace std; // dfs( копия матрицы, кол-во вершин, указатель на юзет, в который будут добавлятся числа Исенбаева, проверяемое ребро, число Исенбаева в данный момент) int dfs(int **gr, int n, int *&q, int v, int k) { for(int i=0;i<n;i++) if ( (gr[v][i]==-1)&&(q[i]==1000) )//если из v в i есть путь и если i не обойдена { q[i]=min(k,q[i]);//чтобы избавится от 1000 dfs(gr,n,q,i,k+1); } return 1; } int main() { int x,i,j,m,n; map<string,int> a; n=0; cin>>m; int **gr=new int*[3*m]; //матрица смежности for(int i=0;i<3*m;i++) gr[i]=new int[3*m]; string s1,s2,s3; for(int i=0; i<m; i++)//ввод фамилий по 3 в строке { cin>>s1>>s2>>s3; if (a[s1]==0) a[s1]=++n; if (a[s2]==0) a[s2]=++n; if (a[s3]==0) a[s3]=++n; gr[ a[s1] ] [ a[s2] ] =-1; gr[ a[s2] ] [ a[s1] ] =-1; gr[ a[s3] ] [ a[s1] ] =-1; gr[ a[s1] ] [ a[s3] ] =-1; gr[ a[s3] ] [ a[s2] ] =-1; gr[ a[s2] ] [ a[s3] ] =-1; }; int k=1; x=a["Isenbaev"]; int *used=new int[n]; for(int i=0;i<n;used[i++]=1000); int *&q=used; cout<<dfs(gr,n,used,x,1); i=0; used[x]=0; for(map<string,int>::const_iterator x=a.begin();x!=a.end();++x,i++) if(used[i]<1000) cout<<x->first<<' '<<used[i]<<endl; else cout<<x->first<<" undefined"<<endl; delete gr,used; return 0; } Could anyone give me the test#6? godsuriyel@gmail.com thanks! I print all answers before now AC,thanks ok Edited by author 09.02.2013 23:40 /* * You should only define the SURC_TEST macros * in the compile directives! */ #include <stdio.h> void main(void) { int nT, a, b, nResult; #ifndef SURC_TEST scanf ("%d", &nT); #else nT = 27; #endif for (int iT = 0; iT < nT; ++iT) { #ifndef SURC_TEST scanf ("%d %d", &a, &b); #else switch (iT) { case 0: a = 30; b = 89; break; case 1: a = 2; b = 16; break; case 2: a = 3; b = 243; break; case 3: a = 1; b = 1; break; case 4: a = 2; b = 2; break; case 5: a = 2; b = 72; break; case 6: a = 1; b = 536870912; break; case 7: a = 1; b = 536870912; break; case 8: a = 1; b = 214358881; break; case 9: a = 1; b = 147008443; break; case 10: a = 1; b = 352275361; break; case 11: a = 1; b = 28934443; break; case 12: a = 1; b = 214921799; break; case 13: a = 1; b = 1042441; break; case 14: a = 1; b = 2627641; break; case 15: a = 1; b = 6086089; break; case 16: a = 1; b = 12823561; break; case 17: a = 1; b = 24730729; break; case 18: a = 1; b = 44930209; break; case 19: a = 1; b = 77810041; break; case 20: a = 1; b = 129254161; break; case 21: a = 1; b = 207561649; break; case 22: a = 1; b = 319730161; break; case 23: a = 1; b = 480091921; break; case 24: a = 1; b = 707081281; break; case 25: a = 1; b = 31973; break; case 26: a = 1; b = 499999999; break; default: a = 1; b = 1; break; } #endif nResult = 0; /********** ALGORITM START ******** * Insert your algorithm here. * input: a, b * result write to: nResult */ // ********* ALGIROTM END ********* #ifndef SURC_TEST printf ("%d\n", nResult); #else int nRightResult; switch (iT) { case 0: nRightResult = 0; break; case 1: nRightResult = 4; break; case 2: nRightResult = 5; break; case 3: case 4: nRightResult = 1; break; case 5: nRightResult = 5; break; case 6: case 7: nRightResult = 30; break; case 8: nRightResult = 9; break; case 9: nRightResult = 6; break; case 10: nRightResult = 5; break; case 11: case 12: nRightResult = 4; break; case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: nRightResult = 3; break; case 25: nRightResult = 2; break; case 26: nRightResult = 3; break; default: nRightResult = 1; break; } if (nResult == nRightResult) printf ("%d\tT\n", iT); else printf ("%d\tF: %d (should be: %d)\n", iT, nResult, nRightResult); #endif } } Edited by author 09.02.2013 22:15 Edited by author 09.02.2013 22:15 who know 13 test . Please help me
If you use dfs, try this test 5 1 3 01000 10111 01000 01000 01000 Answer is: 0 00000 00000 00000 00000 00000 It is rather useful. Thanks. Some tests 7 2 1 2 3 4 5 6 7 Answer 1 5 2 6 3 7 4 7 6 1 2 3 4 5 6 7 Answer 1 3 4 5 6 7 2 This answer can't be right. Only the last column may be smaller. Here 5 columns are smaller. OK, second test is not correct, I think now. ALL tests from the discussion passed and still WA7. Any suggestions? The key for solution was realizing that the ends of the sticks was on the same distance from origin. How to prove that? I have a function F(angleA, angleB). I took derivatives dF/angleA and dF/angleB, they must be equal to zero. Then what? Refer to my new topic :) Cheers var i,j,k,n:longint; begin read(n); for i:=1 to 250 do if sqr(i)=n then begin write(1); exit; end; for i:=1 to 250 do for j:=1 to 250 do if sqr(i)+sqr(j)=n then begin write(2); exit; end; for i:=1 to 250 do for j:=1 to 250 do for k:=1 to 250 do if sqr(i)+sqr(j)+sqr(k)=n then begin write(3); exit; end; write(4); end. If N was bigger, you would have time limit. I don't think so. My code got AC. #include<stdio.h> int i,j,k; long int n; int main() { scanf("%d",&n);
for(i=1;(i*i)<=n;i++) if((i*i)==n) { printf("%d",1); return 0; } for(i=1;i*i<=n;i++) for(j=1;j*j<=n;j++) if((i*i+j*j)==n) { printf("%d",2); return 0; }
for(i=1;i*i<=n;i++) for(j=1;j*j<=n;j++) for(k=1;k*k<=n;k++) if((i*i+j*j+k*k)==n) { printf("%d",3);
return 0; }
printf("%d",4); return 0;
} But this solution is bad. I think it's DP in this problem O(n*sqrt(n)); for(i=1;(i*i)<=n;i++) if((i*i)==n) { printf("%d",1); return 0; } you can just write if (sqrt(n) * sqrt(n) == n) this is the most epic answer I've read....hhhh :) u are awesome thanks dud and good luck # include <math.h> # include <stdio.h> # include <algorithm> using namespace std; int a,b,c,x,y; int main() { scanf("%d %d %d",&a,&b,&c);
for(int i=1;i<10001;i++) { x=0; y=0;
for(int j=1;j<=(int)sqrt((double)i)+1;j++) if(i%j==0) x++;
if(i-c>0) { for(int j=1;j<=(int)sqrt((double)(i-c))+1;j++) if(i%j==0) y++; }
if(b==x && a==y) {printf("%d",i);getchar();getchar();return 0;} }
printf("0");system("Pause"); } //SESC USU SUDO RM -RF var a,b,c,d,i:integer; begin readln(a); readln(b); for i:=1 to 10000 do begin if i mod 2 = 0 then if b-c <> 0 then c:=c+1 else d:=d+1 else if a-c <> 0 then c:=c+1 else d:=d+1; end; case d of 1..200000 : writeln ('yes'); 0 : writeln ('no'); end; end. Edited by author 01.12.2012 17:39 Edited by author 01.12.2012 17:39 Edited by author 01.12.2012 17:39 |
|