| Show all threads Hide all threads Show all messages Hide all messages |
| WA6 | Kirin Vladislav | 1450. Russian Pipelines | 8 Jul 2008 00:32 | 6 |
WA6 Kirin Vladislav 26 Feb 2007 11:59 WA6. What's wrong? Give some test's. In my solution I used Deixtra algo. Re: WA6 Anton [SUrSU] 26 Feb 2007 14:25 Why Dijkstra? Simple dfs for topsort and then dp. Re: WA6 @ntiFreeze 27 Feb 2007 00:57 I think this problem could not be solved with dijkstra. Simple dfs for topsort and then dp or simple BFS :) i used FLOYD's algo and have TLE15. i used Djkstra's algo and i have WA10.. pls, can you give me some tests or what's bug in my program? {$APPTYPE CONSOLE} uses SysUtils; var a:array [1..1000,1..1000] of longint; mas:array [1..1000] of longint; used:array [1..1000] of boolean; i,n,m,t,f:longint; procedure djkstra(st:longint); var cur,i:longint; begin fillchar(mas,sizeof(mas),255); fillchar(used,sizeof(used),0); cur:=st; mas[cur]:=0; repeat used[cur]:=true; for i:=1 to n do if (a[cur,i]<>0) and (mas[i]<mas[cur]+a[cur,i]) then mas[i]:=mas[cur]+a[cur,i]; cur:=0; for i:=1 to n do if not used[i] and (mas[i]<>-1)and ((cur=0)or (mas[cur]>mas[i])) then cur:=i; until cur=0; end; begin read(n,m); for i:=1 to m do begin read(t,f); read(a[t,f]); end; read(t,f); djkstra(t); if mas[f]<>-1 then write(mas[f]) else write('No solution'); halt(0); end. and what to do if there is cycle? Edited by author 16.04.2008 21:52 Edited by author 16.04.2008 21:56 Edited by author 16.04.2008 22:55 i've changed djkstra like this <code>procedure djkstra(x:longint); var cur,i:longint; begin fillchar(v,sizeof(v),-1); fillchar(used,sizeof(used),0); v[x]:=0; cur:=x; repeat used[cur]:=true; for i:=1 to n do if (a[cur,i]<>0) and ((v[i]=-1)or (v[i]<v[cur]+a[cur,i])) then begin v[i]:=v[cur]+a[cur,i]; used[i]:=false; end; cur:=0; for i:=1 to n do if not used[i] and (v[i]<>-1)and((cur=0)or (v[cur]<v[i])) then cur:=i; until cur =0; end;</code> and it's tle#15((( |
| Very nice problem [-] | Chmel_Tolstiy | 1308. Dean's Pyramid | 7 Jul 2008 18:26 | 1 |
|
| why WA1?please supply some test cases | Anupam Ghosh,Bengal Engg and Sc Uni,MtechIT,2006-09,India | 1457. Heating Main | 7 Jul 2008 11:33 | 1 |
does the problem require only finding average that i have done still WA1. can please someone give me some test cases?? Edited by author 08.07.2008 11:04 Edited by author 08.07.2008 11:05 |
| Test resolt | Aleksa_Markoni | 1305. Convex Hull | 7 Jul 2008 07:29 | 2 |
Please can someone tell me what is the answer for this test: 8 1 3 2 2 3 1 4 2 5 3 4 4 3 5 2 4 3.000000 5.000000 1.000000 3.000000 3.000000 1.000000 5.000000 3.000000 |
| gcd function ( C++ ) | Mesh | | 7 Jul 2008 06:23 | 5 |
I know that, at least in GNU compiler ( but it should be standard ) there is ( in cmath, i guess ) a gcd function, called __gcd. But here isn't compilingl why? What should I use instead? write your own gcd() function - it's only three lines of code... I know it's short, but I never remember those damn 3 lines ;P Ok, I'll do that do get the problem accepted, but it would be nice to have a prewritten gcd... This is very easy algo - if you want to be a good programmer, you should know by heart this and more complicated algorithms. The main idea is: while a>0 & b>0 you subtract smaller number from larger (euclid algorithm), but to speed it up we use %: int gcd (int a, int b){ while ((a > 0) && (b > 0)) if (a > b) a %= b; else b %= a; return a+b; }; or, recursively (but slightly slower): int gcd (int a, int b){ if (b == 0) return a; else return gcd (b, a % b); }; Edited by author 07.07.2008 05:06 Yep, but while I like logic and consequently math, I never really studied hard (but as a child I was a prodigy XD) :P But this october I'm gonna start university, so I promised I'll study it... Anyway, I know it's out of topic, but do you know a way to, given an element, know what's its position inside a multiset? I was solving problem 1028, and it would be very easy if I could do that... |
| What´s the test 22? | DaneiL | 1612. Tram Forum | 6 Jul 2008 23:40 | 1 |
|
| 2admins | ftc | 1400. Cellular Characters | 6 Jul 2008 22:11 | 2 |
It seems that test #17 is incorrect. I just increased bounds of arrays in my program from 256 to 1000 and got AC instead of WA17. Could you check that, please. |
| And what is your method of solution? | Vedernikoff Sergey (HSE: EconomicsForever!) | 1396. Maximum. Version 2 | 6 Jul 2008 21:41 | 1 |
I've solved this problem, but in quite a sophisticated way. How did you solve it? May write here or at nick@inbox.ru, using goryinyich as the nick. |
| why WA on 7 ??!?! here is my code | Farhad Ghasemi | 1494. Monobilliards | 6 Jul 2008 21:34 | 2 |
#include<iostream> using namespace std; int array[100000]; int main() { long n; long number,lastnumber=0; cin>>n; long flag=0; for(int j=0;j<100000;j++) array[j]==0; for(long i=0;i<n;i++) { cin>>number; if(array[number-1]==1) { cout<<"Cheater"; return 0; } array[number-1]=1; if(lastnumber) if(!flag) { if(number<=lastnumber) flag=1; } else if(flag) if(number>=lastnumber) { cout<<"Cheater"; return 0; } lastnumber=number;
} cout<<"Not a proof"; return 0; } Test it with these data: 6 3 4 2 1 5 6 Answer is "Not a proof" P.S. Please DO NOT put your code, you can explain your algo. |
| Clarification request | Slobodan | 1505. Oil Transfer | 6 Jul 2008 21:22 | 2 |
Please someone explain sample test case. I don't understand how we can push flow 2 through 1->2 (output shows that) if in the input there is flow capacity 1? In the second line of the input there is 2 1 1 1, 3 1 1 3. that means there is pipeline between 1 and 2 with max flow 1, but there is already 1 flow, so we can't push anything more or something else...? Thank you in advance. read carefully what "d" means. |
| TLE. test #11 | FlashKa | 1024. Permutations | 6 Jul 2008 20:31 | 2 |
[code deleted] Edited by moderator 04.12.2019 20:57 You have a bug in function NOK. It's a overflow bug. |
| TLE. test #11 | FlashKa | 1024. Permutations | 6 Jul 2008 03:25 | 1 |
#include <iostream> #include <memory> using namespace std;
int n; int a[1000], b[1000],c[1000]; int NOK(int a, int b) { int x=a, y=b; while (a!=0 && b!=0) if (a>b) a%=b; else b%=a; return (x*y)/(a+b); } int main() { cin>>n; bool rc=true; for (int i=0; i<n; i++) cin>>a[i]; int p=1; for (int i=0; i<n; i++) { int r=1; b[i]=a[i]; while (b[i]!=i+1) { b[i]=a[b[i]-1]; r++; } c[i]=r; p=NOK(p, c[i]); } cout<<p<<endl; return 0; }
|
| WA 7 Whats wrong? | tanas | 1602. Elevator | 6 Jul 2008 02:40 | 2 |
This is my program. I have read all forum but didn't find answer. Please help {$Q-,R-,S-,I-,O+} program z1602; uses math; var a: array [1..101] of extended; u, v, k, min: extended; pos, i, n: longint; begin read(n,k,u,v); a[1]:= (n-1)*u; for i := 2 to n do a[i]:= max((n-i)*u,(k-1)*v+15)+(i-1)*v+5+(i-1)*v; min:= a[1]; pos:= 1; for i := 2 to n do if a[i] + 1e-9 < min then begin min:= a[i]; pos:= i; end; writeln(pos); end. read problem more attentively. when you find pos, you way from 2 to N, but right way from N downto 2... and you get AC :) Edited by author 06.07.2008 02:43 |
| WA #11 | Russtam | 1602. Elevator | 6 Jul 2008 02:25 | 2 |
WA #11 Russtam 10 Apr 2008 15:58 What's wrong with my function? long double f(int x) { if (x>1) { long double t; if (((k-1)*v+15)>((n-x)*u)) t=(k-1)*v+15; else t=(n-x)*u; return t+(x-1)*v+5+(x-1)*v; } else { return (n-1)*u; } } People give me some tests. Edited by author 10.04.2008 19:46 Your source is right. But please don't remember that "If there are several equivalent variants, output such one in which Petr will go by foot the smaller distance." |
| Was happy to solve, but much interesting understanding why it'is right. [-] | Chmel_Tolstiy | 1397. Points Game | 6 Jul 2008 02:24 | 1 |
|
| Very nice problem [-] | Chmel_Tolstiy | 1368. Goat in the Garden 3 | 6 Jul 2008 02:22 | 1 |
|
| Please, help me. WA C++ | dem | 1001. Reverse Root | 5 Jul 2008 22:17 | 1 |
#include <iostream> #include <iomanip> #include <string.h> #include <math.h> using namespace std; void main( void){ double num[32768]; int sz; sz = sizeof(num) / sizeof(num[0]); for(int i = 0; i < sz; i++ ){ if (cin.eof()){ sz = ++i; break;} cin >> num[i]; } cout << setiosflags(ios::fixed); cout << setiosflags(ios::showpoint); cout << setprecision(4); for(int i = sz - 1; i >= 0; i-- ) cout << sqrt(num[i]) << endl; } |
| Help me to find a mistake please! | RoskaTa | 1585. Penguins | 5 Jul 2008 20:58 | 3 |
This is my source [code deleted] What is wrong? I can't find any mistakes but i always get WA! Please Help me to find my mistake! Thank you! Edited by author 03.07.2008 00:29 Edited by author 05.07.2008 20:59 there are many notes which may help you make your code CLEANer and finding your mistake: 1. use scanf("%d\n",&n) instead of cin>>n (because there cin will not read the '\n' and it will be read by getline) 2.This part may be shortened for(j=0;j<sz;j++) { if(j==0&&s[j]=='L')br++; else if(j==0&&s[j]=='M')br1++; else if(j==0&&s[j]=='E')br2++; } INSTEAD: if(s[j]=='L')br++; else if(s[j]==.... 3. and do not bother yourself with finding the maximum number in this way. you can make it shorter I understood my mistakes and they ware very silly. Thank you Seyyed for helping me ;) Edited by author 30.08.2008 20:34 |
| i got ac without checking cases but searching | frost | 1216. Two Pawns and One King | 5 Jul 2008 18:54 | 2 |
i think it's much easier and faster. Yes, I did the same thing. In this case it is much simpler not to forget something... |
| wa on test 4 | Pripoae Teodor | | 5 Jul 2008 17:45 | 1 |
i get wa on test 4 at problem 1014... is there any special case? |