Common Boardfu 104 fur 83 FBRDub 23 DUDu 1 lrbudf 35 LRBUDF 35 BBUUBB 1 This is my code var n,i:integer; baza:array[1..1000]of string[2]; tmp,bukva:string[2]; begin read(n); i:=0; repeat i:=i+1; readln(baza[i]); until i=n; read(bukva); for i:=1 to n do begin tmp:=baza[i]; if bukva=tmp[1] then writeln(tmp); end; end. Where mystake? I think to this code is right, but i have WA in test1. Help please tmp:=baza[i]; if bukva=tmp[1] then writeln(tmp); mistake there. Edited by author 23.12.2011 13:14 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Тарелки2 { class Program { static void Main(string[] args) { string[] parampidn = Console.ReadLine().Split(' '); int a = int.Parse(parampidn[0]); int b = int.Parse(parampidn[1]); int d = int.Parse(parampidn[2]); string[] muska1 = Console.ReadLine().Split(' '); int r1 = int.Parse(muska1[0]); int r2 = int.Parse(muska1[1]); int minradmuska1 = 0, maxradmuska1 = 0; if (r1 > r2) { maxradmuska1=r1; } else r2 = maxradmuska1; if (r2 > r1) { minradmuska1 = r1; } else minradmuska1 = r2; string[] muska2 = Console.ReadLine().Split(' '); int R1 = int.Parse(muska2[0]); int R2 = int.Parse(muska2[1]); int minradmuska2=0, maxradmuska2=0; if (R1 > R2) { maxradmuska2 = R1; } else maxradmuska2 = R2; if (R2 > R1) { minradmuska2 = R1; } else minradmuska2 = R2; int h = int.Parse(Console.ReadLine()); int minst=0, maxst=0, maxradvel12; if (maxradmuska1>maxradmuska2) { maxradvel12=maxradmuska1; } else maxradvel12=maxradmuska2; if (a>b) { minst=b; } else minst =a; if (a>b) { maxst=a; } else maxst=b; if (((2*maxradmuska1+2*maxradmuska2)<=maxst)&&(2*maxradvel12<=minst)&&(2*maxradmuska1+2*maxradmuska2<= Math.Sqrt((double)a*a+(double)b*b))) { Console.WriteLine("YES"); } else { Console.WriteLine("NO"); } } } } #include<iostream.h> #include<math.h> #include<stdlib.h> bool prov(char s[10]) { int k1=0,k2=0; k1=s[0]-'0'+s[1]-'0'+s[2]-'0'; k2=s[3]-'0'+s[4]-'0'+s[5]-'0'; if(abs(k2-k1)==1)return true;else return false; } int main() { char s[10],str1[10]; int pr=0,k1,k2; cin>>s; if(prov(s)==true) { ltoa(atol(s)+1,str1,10); k1=str1[0]-'0'+str1[1]-'0'+str1[2]-'0'; k2=str1[3]-'0'+str1[4]-'0'+str1[5]-'0'; if(k1==k2)pr=1; ltoa(atol(s)-1,str1,10); k1=str1[0]-'0'+str1[1]-'0'+str1[2]-'0'; k2=str1[3]-'0'+str1[4]-'0'+str1[5]-'0'; if(k1==k2)pr=1; if(pr==0)cout<<"No";else cout<<"Yes"; }else cout<<"No"; return 0; } Bu naqani maslahat bermayman Edited by author 25.02.2007 11:27 Edited by author 25.02.2007 11:27 445219 da nimaga No 4+4+5<=>2+1+9 yani 13 va 12 #include <stdio.h> int main() { int number; int b; int weight; int sum; int sum1; int i; int k; int p; int a[20]; status: scanf("%d", &number); if(number>=1&&number<=20) { for(weight=0;weight<number;weight++) { scanf ("%d", &b); if(b>=1&&b<=100000) a[weight]=b; else weight--; } for(i=0;i<number;i++) { for(weight=0;weight<number;weight++) { if(a[weight]>a[weight+1]) { p=a[weight]; a[weight]=a[weight+1]; a[weight+1]=p; } } } sum=a[number-1]; sum1=a[number-2]+a[number-3]; for(i=4;i<=number;i++) { if((sum1+a[number-i])<=sum) sum1=sum1+a[number-i]; else sum=sum+a[number-i]; } k=sum-sum1; printf ("%d\n", k); } else { printf("enter again\n"); goto status; } return 0; } Edited by author 22.12.2011 18:18 here is the algorithm: #include <iostream> using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout); #endif short *a_list,*d_list; unsigned short a_list_size, d_list_size, a_pos, d_pos; char flag; cin >> a_list_size; a_list = new short[a_list_size]; for (a_pos = 0; a_pos<a_list_size; a_pos++) { cin >> a_list[a_pos];} cin >> d_list_size; d_list = new short[d_list_size]; for (d_pos = 0; d_pos<d_list_size; d_pos++) { cin >> d_list[d_pos];} a_pos = d_pos = 0; flag = 'p'; do { if ((a_list[a_pos]+d_list[d_pos]) > 10000) { if (d_pos == d_list_size) flag = 'n'; else d_pos++; } else if ((a_list[a_pos]+d_list[d_pos]) < 10000) { if (a_pos == a_list_size) flag = 'n'; else a_pos++; } else flag = 'y'; } while (flag == 'p'); if (flag == 'y') cout << "YES"; else if (flag == 'n') cout << "NO"; } what can be wrong? One of solvable by Dijksta with heap. But interesting how to speed up. Idea: use struct (int,int*sqrt(2)) instead of double for distances with compair: (h1,h2*sqrt(2))<(q1,q2*sqrt(2))~ (h1-q1)^2<2*(h2-q2)^2 in int type. i have used other method, and i have best AC 0.265 sec 220 kb One of solvable by Dijksta with heap. But interesting how to speed up. Idea: use struct (int,int*sqrt(2)) instead of double for distances with compair: (h1,h2*sqrt(2))<(q1,q2*sqrt(2))~ (h1-q1)^2<2*(h2-q2)^2 in int type. I have read you massage and after wrote as you said. I got TLE. I changed <<<struct harT{long k1, k2;};>>> on <<<double>>> and get AC. Conclusion: It's not good idea or I don't undestand you. =) Edited by author 22.12.2011 03:53 Edited by author 22.12.2011 03:54Attention: At the beginning, [0, 1000000000)is white,and the second test's output is [..., 1000000000), and in fact you have to deal it with[0, 1000000000 - 1), or you'll got wa. I don't know why! Forgive my english:) Edited by author 13.11.2011 16:28 I saw your solution run at 0.046s, it was really fast. however I use segmentTree to get accept at 0.64s. what kind of algorithm do you use? I don't know what you have been doing, but the bruteforce is 0.156s which is 4.4 times faster than your idea. What I'm trying to say is that you dont need segmentTrees for this problem, unless you want to exercize on them; the naive approach is also very fast :) It seems there are extra characters in test 6! I use following construction: while (scanf("%d") != EOF)) { //proccess test } to be able to proccess several test from one file. With this construction i got WA6. When i proccessed only one test i got Accepted. Test #6 is fixed. Thank you. i got wa on 16 please give me test# 16, i don't know where my mistake: size of heap and arrays are enough. I get WA 16 too. =) I don't know your mistake, but my mistake is ... I use "short". Never use "short"! Use "long" or "__int64". =) Max. count of "boots changes" == 500*500 > 32000. It's funny. =) I think in most cases, true. Why WA5? In my case, it was because I reserved only 20 chars for the language name (no space for the terminating zero). Try this test: 4 12345678901234567891 12345678901234567890 12345678901234567891 unknown answer: Igor is wrong. 0 0 2 -2 1 2 1 1 3 -1 -3 -3 100 Correct answer "-2 1" but my program gave answer "Impossible". =) Do not use the fact that there are only 3 moves left. The traditional minimax is fast and simpler to write. Finally I decided to use your way and I got AC. First of all, I cost tree leafs and then run minimax on the tree. You did in the same way ? On the leaf-costing I don't like how I find index for the child nodes. Is there a more beautiful way then in function below: void costIt( char val=1, char pos = 2 ){ char res = 0; for( char i = 0; i < 3; i++ ){ if ( !arr[ f_x[ i ] ][ f_y[ i ] ] ){ arr[ f_x[ i ] ][ f_y[ i ] ] = val; res = check(); if ( res == 0 ) costIt( val == 1 ? -1 : 1, pos*2+1 ); else if ( !set[ pos > 10 ? (pos-1)/2 : pos ] ){ cost[ pos > 10 ? (pos-1)/2 : pos ] = res; set[ pos > 10 ? (pos-1)/2 : pos ] = true; } arr[ f_x[ i ] ][ f_y[ i ] ] = 0; pos++; } } } Edited by author 20.12.2011 10:24 Hm...Very bad. My programm got AC when i add this code in end program if(ncount==5) if(answer==2) answer=0;(ncount-count of stone) ADMIN READ IT PLEASE pls repair test!!! add this test for example 6 1 4 5 6 7 9 right answer is 0 {(9+7) and (1+4+5+6)}. My program failed this test)) thanks for watching/ Edited by author 25.11.2011 00:45 Edited by author 25.11.2011 00:46 I think these tests are to accept the greedy solution; u know, the "beginners" tag is here for a reason maybe it's right, but problem is very interesting and i want to have right algorithm :) Can you help me for DFA? I am really not sure how to solve the question. Thanks for your help in advance. did anyone make the same mistake? what's that? o,i see now. Can you tell me?I got the WA on #16,too.Thank you. Yes, I have the same problem... I had WA#16 because of the size of the queue. Me too... When I tryed to change array size, I've got TLE#16, then I do a small optimization, and I've got TLE#16 again. I think used algo is incorrect. Use dijkstra+heap (easy to write) or double BFS (fast speed). ----------------------------- Sorry for bad English Edited by author 16.03.2007 17:56 I used double BFS and got AC) I can't understand my mistake( I can't understand what do we need the plain coordinates for. Edited by author 20.12.2008 14:48 For nothing I think. I absolutely ignored coords, used standard Maxflow and got TLe13 because of 0.5 sec. Main point is speed. There are 2 different ways to solve this problem. The first one is to optimize one of the standard Maxflow algorithms to pass TL. The second one is to use the planarity of graph, design an algorithm that is asymptotically faster than the standard ones, and get AC with it. I wrote this problem one year before , with standart maxflow algorithm , and got AC during the contest. Exuse me!.Brilliant the problem, thank the authors. We build dual graph and use Dejkstra in it- O(nlog(n)). But computing dual graph is separated difficult problem from computational geometry connected with walking on grid with extacting faces. Now I am implementing this approach. In test 14 I have situation when starting from some edge and making maximal possible turn to left we don't return to starting edge. Is it possible in comlex geometry or bug in program. Edited by author 18.07.2009 11:05 I've implemented svr's approach and it seems to be the fastest one. I had a lot of problems with my program, but not on test 14 or 15. But I have overcome WA#16 when replaced atan2 with exact geometry. Found: test 14 contains edge with only one facet :) I also have implemented it. Dual graph making is not very easy. But strength (n*log(n)) of this method is great. I used set,vector and had not TL. Edited by author 19.12.2011 12:22 |
|