Show all threads Hide all threads Show all messages Hide all messages | Why IO optimizations don't work? (possible reason of WA#1) | Keworker `~ | 1971. Graphics Settings | 26 Aug 2024 13:19 | 1 | My program use iostream for reading data. Always when i use iostream i add this lines to turn off flushing after each line: signed main(void) { cin.tie(nullptr)->sync_with_stdio(false); cout.tie(nullptr)->sync_with_stdio(false); // solution return 0; } But in this problem program with this lines getting WA#1, without - AC. Why? | Logrithm | yyll | 1971. Graphics Settings | 4 Jun 2021 10:18 | 1 | | To admins | Levon Oganesyan | 1971. Graphics Settings | 13 Oct 2020 23:29 | 2 | In Russian version there is a mistake in the constraints of h. Must be 200, not 260. | MLE 14 | Levon Oganesyan | 1971. Graphics Settings | 3 Oct 2020 01:35 | 1 | MLE 14 Levon Oganesyan 3 Oct 2020 01:35 I had MLE because of bug in segment tree. In test 14: n = 0. | WA8 and WA12 | 💻Evgeny Nemtsev [UrFU]` | 1971. Graphics Settings | 17 Nov 2016 11:44 | 1 | WA8 - all options are off and <10fps WA12 - "Perfect" when >=60fps, NOT >60fps | test 6: Runtime error (access violation), what can it be? | Abram_TA | 1971. Graphics Settings | 31 Oct 2016 17:27 | 3 | Here is my not accepted solution: #include<iostream> #include<string> using namespace std; double P(int power[],string names[],int a,int n,int video_power,int on_or_off[],int w,int h){ a=video_power; for(int i=0;i<n;i++){if(on_or_off[i]==1){a/=power[i];}} double res=a/(w*h); return res; }
int main() { int n; cin>>n; string * names = new string[n]; int * power = new int[n]; for (int i=0;i<n;i++){ cin>>names[i]; cin>>power[i]; } int w,h,video_power; cin>>w>>h>>video_power; double results[100]; int on_or_off[100]; for(int i=0;i<n;i++){on_or_off[i]=1;} int e=0; int a=video_power; for (int i=0; i<n;i++){ a/=power[i]; } double prodyctivity=a/(w*h); results[e]=prodyctivity;e++; int m; cin>>m; for(int i=0; i<m; i++){ string change,change_name; cin>>change; if(change[0]!='R'){ cin>>change_name; for(int y=0;y<n;y++){ if(change=="On" && change_name==names[y]){ on_or_off[y]=1; prodyctivity=P(power,names,a,n,video_power,on_or_off,w,h); results[e]=prodyctivity;e++; } else if(change=="Off" && change_name==names[y]){ on_or_off[y]=0; prodyctivity=P(power,names,a,n,video_power,on_or_off,w,h); results[e]=prodyctivity;e++; } } } else{ int a1,a2; cin>>a1>>a2; w=a1;h=a2; prodyctivity=P(power,names,a,n,video_power,on_or_off,w,h); results[e]=prodyctivity;e++; } } for(int i=0;i<m+1;i++){ if(results[i]<10){cout<<"Slideshow"<<endl;} else if(results[i]>=60){cout<<"Perfect"<<endl;} else{cout<<"So-so"<<endl;} } } Please! I dont know where your mistake is, but anyway this solution is wrong. Check the max test case: n = 99999 and each option is 100 (100^99999). Your double precision not enough for AC. It's 100000 results, not 100 results, hence the access violation on your tiny array | Why WA? | Felix_Mate | 1971. Graphics Settings | 1 Apr 2016 10:31 | 5 | Why WA? Felix_Mate 6 Mar 2016 17:27 По условию ki<=100 => можно поддерживать степень каждого простого числа; при включении или отключении опции мы уменьшаем степень или увеличиваем на соотв. число. В чём обман не знаю. Хотелось бы получить тесты,т.к. на мою фантазию прога работает. const NMAX=105000; MMAX=100; LMAX=10; var a,ki:array[1..NMAX] of int64; step:array[1..MMAX] of int64; step26:array[0..LMAX] of int64; p:array[1..MMAX] of longint; N,i,j,r,m,t:longint; W,H,p0,key,k,res:int64; f:boolean; s,s1:string; procedure QSort(L,R:longint); var i,j:longint; X,Y:int64; begin X:=A[random(r+1-l)+l]; i:=L; j:=R; while i<=j do begin while A[i]<X do i:=i+1; while A[j]>X do j:=j-1; if i<=j then begin y:=A[i]; A[i]:=A[j]; A[j]:=y; y:=ki[i]; ki[i]:=ki[j]; ki[j]:=y; i:=i+1; j:=j-1; end; end; if L<j then QSort(L,j); if i<R then QSort(i,R); end; function Hash(s:string):int64; var i,len:longint; z:int64; begin z:=0; len:=length(s); for i:=0 to len-1 do inc(z,(ord(s[len-i])-ord('a'))*step26[i]); Hash:=z; end;
function Search(L,R:longint;key:int64):int64; var m:longint; begin while(R-L>1) do begin m:=(L+R) div 2; if(a[m]<=key) then L:=m else R:=m; end;
if(a[L]=key) then Search:=ki[L] else Search:=ki[R]; end;
procedure Update(x:int64;sgn:longint); var i:longint; begin i:=1; while(i<=r) do begin while(x mod p[i]=0) do begin x:=x div p[i]; inc(step[i],sgn); end; inc(i); end; end;
BEGIN randomize; r:=1; p[r]:=2; for i:=3 to MMAX do begin f:=true; for j:=2 to i-1 do if(i mod j=0) then f:=false; if(f) then begin inc(r); p[r]:=i; end; end;
for i:=1 to r do step[i]:=0;
step26[0]:=1; for i:=1 to LMAX do step26[i]:=step26[i-1]*26;
readln(N); for i:=1 to N do begin readln(s); t:=pos(' ',s); s1:=copy(s,1,t-1); delete(s,1,t); val(s,ki[i],t); a[i]:=Hash(s1); Update(ki[i],1); end;
Qsort(1,N);
readln(W,H,p0); readln(m);
res:=W*H; i:=1; while(res<=p0)and(i<=r) do begin j:=step[i]; while(j>0)and(res<=p0) do begin res:=res*p[i];dec(j);end; inc(i); end;
if(p0<10*res) then writeln('Slideshow'); if(p0>=10*res)and(p0<60*res) then writeln('So-so'); if(p0>60*res) then writeln('Perfect');
for i:=1 to m do begin readln(s); if(s[2]='n') then begin t:=pos(' ',s); delete(s,1,t); key:=Hash(s); k:=Search(1,N,key); Update(k,1); end; if(s[2]='f') then begin t:=pos(' ',s); delete(s,1,t); key:=Hash(s); k:=Search(1,N,key); Update(k,-1); end; if(s[1]='R') then begin t:=pos(' ',s); delete(s,1,t); t:=pos(' ',s); s1:=copy(s,1,t-1); delete(s,1,t); val(s1,w,t); val(s,h,t); end;
res:=W*H; t:=1; while(res<=p0)and(t<=r) do begin j:=step[t]; while(j>0)and(res<=p0) do begin res:=res*p[t];dec(j);end; inc(t); end;
if(p0<10*res) then writeln('Slideshow'); if(p0>=10*res)and(p0<60*res) then writeln('So-so'); if(p0>60*res) then writeln('Perfect'); end; END. Банальное (p0>60*res) -> (p0>=60*res) в двух местах. Если будет время, напиши мне пожалуйста? Что именно написать : как я решать пытаюсь, вердикты на попытки или что-то ещё? На емайл, т. к. есть вопрос по другой задаче. Сам отвечу себе))) Ошибка находилась в строках if(s[2]='f') then begin ... и if(s[1]='R') then begin ..., т.к. в первом условии s менялось и могло попасть во второе или третье; P.S. задачу сдал без хэшей: можно просто отсортировать строки. | WA9 | Arsen Babakhanyan (AUA) | 1971. Graphics Settings | 12 Oct 2015 05:45 | 2 | WA9 Arsen Babakhanyan (AUA) 3 Aug 2013 20:49 getting WA9 What can be the problem ? Re: WA9 Jane Soboleva (SumNU) 12 Oct 2015 05:45 WA9 happens when in attempt of optimization you try to convert the name of an option into int64, but miserably fail at that. Like, (1..26)27^0 + (1..26)27^1 + (1..26)27^2 + ... I simply forgot the increment, so i had (1..26)27^0 + (1..26)27^0 + (1..26)27^0 + ... | Why G++ 8.7.1 is TLE 2.031, When Visual C++ is giving Accepted ? | Meirambek | 1971. Graphics Settings | 25 Dec 2014 16:17 | 3 | Probably, IO workload is different. I had similar issue - G++ 4.9 gives WA9, while Visual C++ 2010 is ok. | WA#2 | DannyPhantom | 1971. Graphics Settings | 5 Nov 2013 19:43 | 3 | WA#2 DannyPhantom 8 Sep 2013 02:27 Can someone give me an input example with the right output so I could check it, 'cause all the test I run are right Re: WA#2 Межгалактическая Академия Транспневматологии 8 Sep 2013 18:46 | Test 7 | Nakatengga | 1971. Graphics Settings | 11 Oct 2013 00:19 | 1 | Test 7 Nakatengga 11 Oct 2013 00:19 I am getting Time limit exceeded.. Maybe someone had the same problem? What can it be? help please | Помогите с 6 тестом... | Nakatengga | 1971. Graphics Settings | 8 Sep 2013 18:43 | 2 | Совсем не могу понять почему не проходит 6 тест, проблема у меня не 59,9 как было у другого задовавшего вопрос... lual.ru Edited by author 08.09.2013 18:45 | No subject | daria | 1971. Graphics Settings | 23 Aug 2013 01:06 | 1 | Edited by author 23.08.2013 19:43 Edited by author 23.08.2013 19:43 | How solve this problem? | Dmitry | 1971. Graphics Settings | 4 Aug 2013 17:17 | 1 | | test 6 | Ilya Lopukhin | 1971. Graphics Settings | 3 Aug 2013 14:33 | 3 | test 6 Ilya Lopukhin 3 Aug 2013 13:56 Somebody had a wrong answer in test 6? I can't understand what exactly can be wrong :( Please, help I had it when my program printed Perfect when FPS was 59.9 Edited by author 03.08.2013 14:32 |
|
|