Общий форум| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | | Problem is locked until incorrect tests will be fixed | Vladimir Yakovlev (USU) | 1524. Men in Black | 29 янв 2010 18:11 | 2 | Problem is unlocked, you may submit solutions, but there still may be errors Edited by author 29.01.2010 18:11 | | WA#3 | Iosif inf-10 | 1744. Рота Капитана | 29 янв 2010 17:46 | 4 | WA#3 Iosif inf-10 24 янв 2010 16:00 what is wrong in my solution? Program N1744; Var n,i,j,t,k:integer; A:array[1..100,1..100] of integer; R:array[1..50000,1..3] of integer; begin Readln(n); for i:=1 to N do for j:=1 to N do if i<>j then A[i,j]:=0 else A[i,j]:=3; k:=0; for i:=1 to N do for j:=1 to n do for t:=1 to n do if (A[i,j]<3)and(A[i,t]<3) and(A[j,t]<3) then begin inc(k); R[k,1]:=i; R[k,2]:=j; R[k,3]:=t; inc(A[i,j]); inc(A[i,t]); inc(A[j,t]); inc(A[j,i]); inc(A[t,i]); inc(A[t,j]); end; writeln(k); for i:=1 to k do writeln(R[i,1],' ',R[i,2],' ',R[i,3]); Readln; end. is there a difference in what order the output numbers of soldiers? Edited by author 24.01.2010 16:02 Edited by author 24.01.2010 16:03 For n=7 your program returns k=13 and for n=9 k=28, but correct answers are 21 and 36 Edited by author 27.01.2010 04:07 Can you write full output for n=7 ? For example, 21 1 2 3 1 2 3 1 2 3 1 4 5 1 4 5 1 4 5 1 6 7 1 6 7 1 6 7 2 4 6 2 4 6 2 4 6 2 5 7 2 5 7 2 5 7 3 4 7 3 4 7 3 4 7 3 5 6 3 5 6 3 5 6 I hope, it will help you. | | How to solve this? | sandtea | 1745. Ещё Один Ответ | 29 янв 2010 10:37 | 1 | I tried to use dynamic programming but failed.Who can tell me how to do it? Thank you very much! | | Why WA test 5 | Samvel Petrosov | 1021. Таинство суммы | 28 янв 2010 21:23 | 5 | here is my algo #include <iostream> #include<algorithm> using namespace std; int main() { const int N=50000; int a[N],b[N],i,n,k,c[N],d[N],s=0; bool p=true; cin>>n; for(i=0;i<n;i++) cin>>a[i]; cin>>k; int j=k-1; for(i=0;i<k;i++) cin>>b[i]; int x=0,y=0; for(i=0;i<n;i++) c[x++]=a[i]; for(i=0;i<k;i++) d[y++]=b[i]; nth_element(c,c,c+n); nth_element(d,d,d+k); for(i=n-1;i>=0;i--) { while(j>=0) { s=d[j]+c[i]; j--; if(s==10000) { p=true; break; } else p=false; } if(p==true) break;
} if(p==true) { cout<<"YES"<<endl; } else cout<<"NO"<<endl; return 0; } // code removed ! issue resolved !! Edited by author 13.01.2010 20:25 use Quick sort: int Partition(int low,int high,int a[]) { int high_vac,low_vac,pivot; pivot=a[low]; while(high>low) { high_vac=a[high]; while(pivot<high_vac) { if(high<=low)break; high--; high_vac=a[high]; } a[low]=high_vac; low_vac=a[low]; while(pivot>low_vac) { if(high<=low)break; low++; low_vac=a[low]; } a[high]=low_vac; } a[low]=pivot; return low; } void Quicksort(int low,int high,int a[]) { int Piv_index; if(low<high) { Piv_index=Partition(low,high,a); Quicksort(low,Piv_index-1,a); Quicksort(Piv_index+1,high,a); } } then binary_search Samo es el kez quicksort Edited by author 28.01.2010 21:14 Samo es test@ stugi: 3 0 0 10000 3 10000 10000 0 | | Invitation to Programming Contest | Yash | | 28 янв 2010 19:01 | 1 | Hello, The International Institute of Information Technology, Hyderabad, India cordially invites you to be a part of Felicity, the annual cultural and technical festival, to be held from 19th - 21st February,2010. 1) Codecraft 2010 CodeCraft 2010, the online programming competition is all set to start on 14th February,2010. Codecraft requires eight hours of brainstorming over some of the toughest algorithms challenges from various fields of Computer Science. Where : http://felicity.iiit.ac.in/codecraft/When : 14th February , 2010 , 2 pm - 10 pm IST(GMT +5:30). 2) Time Limit Exceeded This is an unusual programming event which emphasizes on solving problems under special constraints. The event is based on C/C++ with the scoring depending on factors like code length, deviation from the best available solution, or even the number of semi-colons and whitespaces used. Where : http://felicity.iiit.ac.in/tleWhen : 15th February 2010 2pm to 17th February 2pm (48 hours [2 days]) IST (GMT +5:30). 3) MathematiKa 2010 MathematiKa 2010 is an online mathematical programming contest which emphasizes on fusion of mathematics and computing. Contestants may use ANY language of their choice. Where : http://felicity.iiit.ac.in/~mathWhen : 17th February, 2010 , 4pm - 12pm IST(GMT +5:30). You need to REGISTER online to participate in these event. There are prizes in each of the mentioned events, details of which will be put on the site in due time. Kindly visit the respective sites for more details. For queries , mailto : codecraft10@gmail.com , tle10.001@gmail.com, mathematika1.2k10@gmail.com -- Thanks and Regards Team Felicity 2K10 | | WA48 | vgu | 1637. Игра в треугольник 2 | 27 янв 2010 16:14 | 1 | WA48 vgu 27 янв 2010 16:14 Why WA48? Please, give some tests. | | Pairs | typedef | | 26 янв 2010 15:09 | 2 | Pairs typedef 26 янв 2010 13:59 Hello! I have the following task: I have 2 groups: boys and girls. Each boy has a list of girls' names. The list contains girls he want to dance with. Each girl has the same list with boys' names. I khow, that the quantity of girls is not less, than the quantity of boys. I have to answer the question: are there pairs boy-girl (in each pair the guys want to dance with each other) when all girls will dance? Each list is not empty. Please, give me an idea to solve this problem. Thank you. 0) If girls > boys, the answer, obviously, NO. If girls==boys 1)Build graph with two parts: boys and girls. 2) If some girl(i) want to dance with some boy(j) you add edge (i,j) with weight 1 into your graph. 3) Find maximal biparite matching (if you can't look it in google) 4) If MaxBipMatching==girls count the answer is yes. Otherwise NO. | | Is string comparing case-sensitive? | Ilya Porublyov | 1732. Министерство правды | 26 янв 2010 13:07 | 2 | Is string comparing case-sensitive? | | How store data in Java? | KALO | 1590. Шифр Бэкона | 26 янв 2010 11:44 | 5 | I have a good hash function (I think), but i don`t know how to store the hash codes for fast access. please help Edited by author 12.07.2009 06:39 Use an array of hashes of all preffix of the string!
use hash table... it's simple and fast. AC KALO 26 янв 2010 01:26 Finally I managed to get AC with O(n^2logn) suffix array. Re: AC Baurzhan 26 янв 2010 11:44 This problem can be solved with prefix-function in O(N^2) and sizeof(bool)*5000*5000 memory. | | WA1 - HINTS | Leonid (SLenik) Andrievskiy | 1104. Не спрашивай даму о возрасте | 25 янв 2010 23:10 | 1 | WA1 - HINTS Leonid (SLenik) Andrievskiy 25 янв 2010 23:10 Be careful! The input string may contain spaces and/or line breaks! | | why WA on test#3 | Головченко Дмитрий | 1084. Пусти козла в огород | 25 янв 2010 21:49 | 2 | uses SysUtils ,Math; Var a, R:integer; s :Real; begin ReadLn(a,R); If R > 0.5*a then S := pi*R*R + 2*a*sqrt(R*R-0.25*a*a) -4*R*R*arcCos(0.5*a/R); else S := pi * R*R; WriteLn(S :0:3); end. You didn't write another one requirement for this programm | | wa1? | zsyzzsx2 | 1002. Телефонные номера | 25 янв 2010 17:55 | 1 | wa1? zsyzzsx2 25 янв 2010 17:55 I passed the test in the problem. But why I couldn't pass the first test? Here are my program: var s,s2:string; n,i,j,k,l:longint; s1,c:array[1..50000]of string; m:array[1..100,1..100]of integer; b:boolean; function xun(len:longint):boolean; var j:longint; begin if j=1 then begin xun:=true; exit; end; for j:=len-1 downto 1 do begin if m[j,len]>0 then begin if xun(j) then begin write(s1[m[j,len]],' '); end; end; end; end; begin //assign(input,'1002.in');reset(input); readln(s); repeat l:=length(s); readln(n); for i:=1 to n do begin b:=false; readln(s1[i]); for j:=1 to length(s1[i]) do case s1[i][j] of 'i','j':c[i]:=c[i]+'1'; 'a','b','c':c[i]:=c[i]+'2'; 'd','e','f':c[i]:=c[i]+'3'; 'g','h':c[i]:=c[i]+'4'; 'k','l':c[i]:=c[i]+'5'; 'm','n':c[i]:=c[i]+'6'; 'p','r','s':c[i]:=c[i]+'7'; 't','u','v':c[i]:=c[i]+'8'; 'w','x','y':c[i]:=c[i]+'9'; 'o','q','z':c[i]:=c[i]+'0'; end; for j:=1 to l-length(c[i])+1 do begin s2:=copy(s,j,length(c[i])); if s2=c[i] then m[j,j+length(c[i])-1]:=i; end; end; for j:=length(s)-1 downto 1 do begin if m[j,length(s)]>0 then begin if xun(j-1) then begin b:=true; write(s1[m[j,length(s)]]); break; end; end; end; if b=false then write('No solution.'); readln(s); writeln; fillchar(s1,sizeof(s1),0); fillchar(c,sizeof(c),0); fillchar(m,sizeof(m),0); until s='-1'; //close(input); end. | | Take this test into consideration | Farhad Ghasemi | 1431. Сертификаты | 25 янв 2010 10:58 | 1 | 4 14 13 14 13 the answer is 2! | | TLE Test 5 | Prabhjot Singh | 1752. Дерево 2 | 25 янв 2010 07:27 | 1 | my algorithm is quite simple and i dont know how to make it fast. my hints would be appreciated. 1. i am using dfs to get the distance from vertex v to vertex u such that dist(v, u) = d given. 2. while computing the vertex u..i am saving the result of all previous vertices u1, u2, ....ud..such that distance between v and u1 is 1, v and u2 is 2 and so on. i am saving the result in hashmap. 3. i only use dfs if the hashmap doesnt contain the query. I can email my code as well.... Thanks | | Why Crash (access violation)? | FeDoS (ONPU) | | 24 янв 2010 23:41 | 1 | Problem 1008 C++ #include <iostream> using namespace std; int main() { int col,x,y,nowx[7],nowy[7],now=1; nowx[1]=11;nowy[1]=11; int p[11][11]; int i,j; scanf("%d",&col); for(i=1;i<11;i++){ for(j=1;j<11;j++){ p[i][j]=0; } } for(i=1;i<col+1;i++){ scanf("%d %d",&x,&y); p[x][y]=1; } for(i=1;i<11;i++){ for(j=1;j<11;j++){ if (p[i][j]==1){ if(nowx[1]>i) nowx[1]=i; } } } for(j=1;j<11;j++){ if (p[nowx[1]][j]==1){ if(nowy[1]>j) nowy[1]=j; } } p[nowx[1]][nowy[1]]=0; printf("%d %d\n",nowx[1],nowy[1]); for(i=1;i<col+1;i++){ if (p[nowx[i]-1][nowy[i]]==1) { now++; nowx[now]=nowx[i]-1; nowy[now]=nowy[i]; p[nowx[i]-1][nowy[i]]=0; printf("L"); } if (p[nowx[i]][nowy[i]-1]==1) { now++; nowx[now]=nowx[i]; nowy[now]=nowy[i]-1; p[nowx[i]][nowy[i]-1]=0; printf("B"); } if (p[nowx[i]+1][nowy[i]]==1){ now++; nowx[now]=nowx[i]+1; nowy[now]=nowy[i]; p[nowx[i]+1][nowy[i]]=0; printf("R"); } if (p[nowx[i]][nowy[i]+1]==1){ now++; nowx[now]=nowx[i]; nowy[now]=nowy[i]+1; p[nowx[i]][nowy[i]+1]=0; printf("T"); } if (col!=i) printf(",\n"); } printf("."); return 0; } | | TLE 21. Can anybody help? | wRabbits_nevidomy(VNTU) | 1752. Дерево 2 | 24 янв 2010 16:19 | 2 | | | Why could I POSSIBLY have a wrong answer on the FIRST test?! | Zrutor | 1236. Decoding Task | 24 янв 2010 03:16 | 1 | I checked my program, and I'm pretty sure that it gives the correct answers for the sample input/output, and for all the tests given on this forum. I also went to the page of NEERC 2002 and downloaded their test examples, and everything seems to be correct. I tried ending output with or without a newline('\n'), and I still can't figure out why I could possibly be getting a wrong answer three times in a row. Please give me some advice as to where my problem is. Maybe it is someting small? Maybe I misread something in the problem statement? Anyway, here's my program(I'm sure the code is pretty bad, but keep in mind that I don't have much experience with these sorts of problems): #include <iostream> #include <iomanip> using namespace std; int main() { int A[10002]; long int pos = 0;
cin.unsetf(ios::skipws);
do { char input[3];
cin >> input[0];
if(input[0] == '\n') break;
cin >> input[1];
input[2] = 0;
A[pos] = (int) strtol(input, (char **) input + 2 * sizeof(char), 16); pos++;
} while(1);
int current; int key;
char input[3]; input[0] = 'C'; input[1] = '9'; input[2] = 0;
cin >> input[0] >> input[1]; key = (int) strtol(input, (char **) input + 2 * sizeof(char), 16); key ^= 32;
for(int i = 0; i < pos; i++) { cout << hex << uppercase << setfill('0') << setw(2) << key;
cin >> input[0] >> input[1];
current = (int) strtol(input, (char **) input + 2 * sizeof(char), 16);
key = ((key) ^ (A[i])) ^ (current); }
cout << hex << uppercase << setfill('0') << setw(2) << key << "\n";
return 0; } Please help! Any advice will be appreciated! | | tests | LSBG | 1743. Сортировка домино | 24 янв 2010 02:06 | 1 | tests LSBG 24 янв 2010 02:06 Finally I got accepted. I include several tests to help you debug: input output: 8 YES 1 70 1 70 4 65 4 65 64 66 61 64 61 64 65 64 66 62 66 64 80 50 66 62 80 60 80 60 65 64 80 50 input: output: 3 YES 1 3 1 3 2 1 1 2 2 3 3 2 | | That easy!! :) | Vasya Pupkin | 1313. К вопросу о спорте | 23 янв 2010 21:59 | 1 | var n,i,j,l:integer; a:array[1..100,1..100] of integer; begin read(n); for i:=1 to n do for j:=1 to n do read(a[i,j]); i:=1; j:=1; for l:=1 to n do begin i:=l; j:=1; while i<>0 do begin write(a[i,j],' '); dec(i); inc(j); end; end; for l:=n + 2 to n + n do begin i:=n; j:=l - n; while j <= n do begin write(a[i,j],' '); dec(i); inc(j); end; end; readln; readln; end. | | Timus team | exod40 | | 23 янв 2010 18:55 | 1 | How can i reach acm.timus team? I tried to write an e-mail, but it returned to me with some errors in their mailing box. |
|
|