Common BoardGive plz some tests Edited by author 21.10.2007 22:20 Edited by author 21.10.2007 22:20 8 8 3 4 2 4 5 4 5 3 6 1 2 1 2 3 1 5 6 1 6 7 1 7 8 1 2.00 -1.00 2.00 0.00 4.00 -3.00 4.00 -3.00 В чём ошибка не пойму.? не проходит 1 тест var i,j,k,m,s,n:integer; a,b:array[1..100000] of integer; begin read(n); k:=0; for i:=1 to n do read(a[i]); read(m); for i:=1 to m do read(b[i]); for i:=1 to n do begin for j:=1 to m do begin if a[i]+b[j]=10000 then k:=1; end; end; if k=1 then write('yes'); if k=0 then write('no'); end. Edited by author 05.02.2011 21:26 Edited by author 05.02.2011 21:30 Try to use capital letters for the answer: YES and NO Исправь "yes" и "no" на "YES" and "NO". Однако после этого будет ТЛЕ на 4 тесте. Используй быструю сортировку и бинарный поиск. Удачи! Sorting not needed because input given in sorted order. Actually you even not need to binary-search, just line scan of both arrays. Think what way summ changed if you pick next item in array. IMHO sortirovka zdes ninado And? As you can see from the problem statistics, many people did it in 0.001s and some of them - with 117 kb =) RT. I want to know what data is on test #6 test #1 6 7 0 0 0 0 0 my program output "2\n1 2" but gets WA#1 yes, you are right my cheat program: var N; begin readln(N); readln(N); readln(N); if (N=0) then 10 div 0 else InfinityRecursion end. of course, read(N); i am in despair. it work! test it! at least once for sample input it write sample output. i don't use any random, but it gets WA1 //code deleted Edited by author 13.06.2006 23:27 ht[heap[hp].nexN&0x7FF]=hp++; //It's wrong! ht[heap[hp].nexN&0x7FF]=hp++; //It's wrong! why it's wrong? it's equivalent line: ht[heap[hp].nexN&0x7FF]=hp; hp++;
ht[heap[hp].nexN&0x7FF]=hp; hp++; //It's right! and after finding of all mistakes, you get the TLE#6... 6 1 2 3 4 5 6 3 1 1 2 3 1 2049 4097 Edited by author 11.06.2006 05:08 я извиняюсь, мне просто не сказать этого по английски :) я запостил не ту версию программы, в этой есть баги. да не в этом дело я написал программу которая даёт правильный ответ на sample#1 причём даже в той же последовательности выводит номера. моя программа даёт ответ: 4 4 5 1 6 но проверяющая система выносит вердикт: WA#1 я закомментировал вывод ответа и написал в конце printf("4\n4 5 1 6"); такая программа получает WA2 вопрос: как такое может быть, что одна программа получает WA2, а вторая WA1 я не однократно проверил что программы на этот sample выдают один и тот же ответ может быть причина в том, что я вывожу числа так: for (i=0;i<chetotam;i++) printf("%d ",int_ar[i]); мешает лишний пробел? это глупо, и маловероятно. перед выводом нет перевода строки. больше мне ничего в голову не приходит На всякий случай убери лишний пробел, моя АС прога не выводит его... Your solution is verified by a checker written by Ilya Grebnov, and no one still claimed it works wrong. I want you to send me both you WA(1) and WA(2) solutions for investigation. If some bug in the checker is found I will fix it. My e-mail for Russian-speaking programmers is dimanyes@mail.ru sent. I write a new program - WA12 :) I send. You forgot about? I have nothing to say. Everything is ok on my Borland C++ Builder compiler. You must contact with Vladimir Yakovlev to investigate this problem because he is C++ programmer. I have forwarded your mail to him. can you give me his e-mail? you know my, sent it. Your program works wrong on sample input. Test it with other compiler. For example, with Intel C++ Compiler 7.0 I have only Visual Studio 6 & 2005 in this IDE my program writes right answer I have same problem. On 1 test my program output: 4 6 1 5 4 but WA1. Why? I have 1 test runs but on the server WA test 1!!??? program pro; var n,k,t:byte; s:string; sum:integer; BEGIN read(n,s); t:=1; k:=length(s)-1; if n mod k=0 then begin sum:=n; while n-t*k>0 do begin sum:=sum*(n-t*k); t:=t+1; if sum*(n-t*k)<0 then break; end; sum:=sum*k; end else begin sum:=n; while n-t*k>0 do begin sum:=sum*(n-t*k); t:=t+1; if sum*(n-t*k)<0 then break; end; sum:=sum*(n mod k); end; write(sum); END. 9 !! My program write 945 and why WA 1?????? #include <iostream> using namespace std; int main(){
int a = 0; int b = 1; int c = 0; int k = 0;
cin >> a;
if(a > b){ k = 1;
for(; b <= a; b = b + k){
c += b;
}
}
else if(a < b){
k = -1;
for(; b >= a; b = b + k){
c += b;
}
}
cout << c; } Edited by author 19.10.2013 16:35 Edited by author 19.10.2013 16:35 if n=10 then first column is that: 2 3 4 5 6 7 10 11 12 13 AC'ed authors, how could you fix this? Try to do all calculations in integer numbers I even replaced all the doubles with integers. But the result is the same. In my formula, overflow is possible even in long long, if computed straightforwardly. So, check that in your algo no overflow occurs. #include <stdio.h> #include <vector> #define pb push_back #define For(i,n) for(int i=0;i<n;i++) using namespace std; int main() { int n,m,k; vector < int > w; vector < int > v; scanf("%d%d%d",&n, &m, &k); For(i,n) { int x; scanf("%d", &x); w.pb(x); } For(i,m) { int x; scanf("%d", &x); x--; v.pb(x); } int ind=0; int tek=0; int ans=0; long long i=0; vector < int > solve; while (true) { if (ind<v.size() && i==v[ind]) { int kol=0; while (kol<=k && solve.size()>0) { w.pb(solve[solve.size()-1]); solve.pop_back(); kol+=w[w.size()-1]; } ind++; i++; continue; } solve.pb(w[0]); w.erase(w.begin()); i++; if (w.size()==0 || solve.size()==n)break; } printf("%d", i); } I have WA 11. My solution very similar to yours. I don't have any idea what is wrong. BTW. If you use long long, you must use %lld in printf instead %d. #include <stdio.h> int n,m,k; int w[10000]; int t[10000]; long long d; void swap(int i, int j) { int t; t = w[i]; w[i] = w[j]; w[j] = t; } int caving(int i) { int s = 0; int c = 0; int j; while ((s <= k) && (i > 0)) { i--; s += w[i]; c++; } /*for (j = 0; j < c/2; j++) { swap(i+j,i+c-j-1); }*/ return c; } int main() { int i,j; int cw, ct; #ifndef ONLINE_JUDGE freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout); #endif scanf("%d %d %d\n", &n, &m, &k); for (i = 0; i < n; i++) scanf("%d", &w[i]); for (i = 0; i < m; i++) scanf("%d", &t[i]); cw = 0; ct = 0; d = 0; do { d++; if ((ct < m) && (t[ct] == d)) { ct++; cw -= caving(cw); } else cw++; } while (cw < n); printf("%lld\n", d); return 0; } Hello, Kot! > int w[10000]; > int t[10000]; >> 1 ≤ n, m ≤ 10^5 I think yon need [100000] arrays. I had a step-by-step solution which caused TL 11. I've improved it to event-by-event solution but nothing changed. I translated it from Java to Visual C 2010 using your data loader and got WA11. Replaced w[10^4] by w[10^5] - and finally I've got TL11. I don't have any good idea and wonder about better algorithm or a bug which causes an endless loop... Could you try to fix it and write your solution result? Brute force solution works fine after some optimizations. Look at n and m limits - it is possible that Luke will drop same stones more than once. Finally my solution has been accepted. It's definitely a brute force one, but using optimization for all loops, which can be run undefined number of times. did you use binary search in your solution? "Each player has his own specified starting position", means that the starting positions of the players is different? Yes, that actually means it. You could see both positions in the last string of input. No, in test 3, they both start in the same position. if((a[2]+a[3]+a[4])%2==a[5] && (a[1]+a[3]+a[4])%2==a[6] && (a[2]+a[1]+a[4])%2==a[7]) shu bajarilguncha ketma-ketlikni o'zgartirib borasiz 0 bo'lsa 1 va aksincha 1 bo'lsa 0 Masalan: 0 1 0 1 1 0 1 for petal 0 1 0 1 1 0 1 1 0 1 for petal 0 0 1 0 0 0 1 1 0 1 for petal 1 1 1 0 1 1 1 1 0 1 for petal 1 0 0 0 1 0 0 1 0 1 for petal 1 0 1 Edited by author 30.09.2013 14:39 Mana tayyor kod!!! [code deleted] Edited by Muzaffardjan Karaev M.K _77 )))xD 11.11.2013 11:11 Edited by author 12.11.2013 19:58 Edited by moderator 24.11.2019 12:42 Can anyone please describe the test case? How can it be as low as 0.66667? - First night one good senator dies. We have 2 good senators and 1 spy. - First day senators choose to kill 2 people. They have a 66.6% chance that they get the spy and a good guy remains, 33.3% chance that the spy lives. Я один раскладывал 2*n на всевозможные множители?) "At some moment of time two players can be located in the same cell." If this occurs, who will take the number in that cell? If both of them can take,then they can meet at some point and simultaneously take the number.That will maximize their score. They move in turns, not simultaneously, so even if they end up in one cell one of them (player one) must have stepped there first and therefore he must have taken the points from that cell. Thanks []zhi(Bozhin Katsarski) I have WA#11, though my decision is consisted only from integer numbers. What is possible problem? Edited by author 11.11.2013 17:03 Edited by author 11.11.2013 17:04 Edited by author 11.11.2013 17:04 My program passed all tests from forum, but It gets WA28 Here is my code: Var ygol,arm,otkl,energy,us,ensrus,enemys,ensrzapas : int64; s : string; Function Min(x,y : int64):int64; Begin if x > y then Min := y Else Min := x; End; Procedure Oxrana; Begin if enemys = 0 then Writeln('STOP') Else if Abs(ygol) < 5 then Writeln('FIRE ',Min(20,arm)) Else if ygol > 0 then Writeln('LEFT ',Min(100,energy)) Else Writeln('RIGHT ',Min(100,energy)); End; Procedure Atack; Begin if us*ensrus > enemys*ensrzapas*3 then if Abs(ygol) < 10 then Writeln('FIRE ',Min(20,arm)) Else Writeln('FRONT ',Min(100,energy)) Else if Abs(ygol) < 5 then Writeln('FIRE ',Min(20,arm)) Else Writeln('BACKWARD ',Min(100,energy)) End; Procedure Defence; Begin if enemys*20 >= Arm then if Abs(ygol) < 5 then Writeln('FIRE ',Min(20,arm)) Else Writeln('BACKWARD ',Min(100,energy)) Else Oxrana; End; Procedure Patrul; Var t : longint; Begin t := otkl; if otkl < 0 then Otkl := Otkl+360; if enemys > 0 then Defence Else if (Otkl>=160) and (otkl <= 200) then Writeln('BACKWARD ',Min(100,energy)) Else if ((otkl >= 0) and (otkl <= 20) or (otkl >= 340) and (otkl <= 360)) then Writeln('FRONT ',Min(100,energy)) Else if t > 0 then Writeln('LEFT ',Min(100,energy)) Else Writeln('RIGHT ',Min(100,energy)); End; BEGIN Readln(Energy,Arm); Readln(s); Read(enemys,ensrzapas,ygol); if Pos('A',s) <> 0 then Begin Read(us,ensrus); Atack; End; if Pos('D',s) <> 0 then Defence; if Pos('G',s) <> 0 then Oxrana; if Pos('P',s) <> 0 then Begin Read(otkl); Patrul; End; END. This test, please: 4 100 P 0 123 45 128 I hope it'll help you! :))) program spiral; var n,m,r:real; begin readln(n,m); if m>=n then begin if n=1.0 then r:=0.0 else if n=2.0 then r:=2.0 else if frac(n/2)<>0 then r:=4.0*trunc(n/2) else r:=2.0*(n-1); end else begin if m=1.0 then r:=1.0 else if m=2.0 then r:=3.0 else if frac(m/2)<>0 then r:=4.0*trunc(m/2)+1.0 else r:=2.0*m-1.0; end; writeln(r:0:0); end. const{only 49K) maxn=11; var a:array[0..maxn]of 0..9; n,m:longint; i,j,s:integer; ok:boolean; begin fillchar(a,sizeof(a),0); readln(n,m); ok:=false; if n>m then begin n:=m;ok:=true;end; n:=n-1; i:=maxn+1; while n<>0 do begin i:=i-1; a[i]:=n mod 10; n:=n div 10; end; if ok then j:=1 else j:=0; for i:=maxn downto 1 do begin s:=a[i]*2+j; a[i]:=s mod 10; j:=s div 10; end; i:=0; while (a[i]=0)and(i<>maxn) do i:=i+1; for j:=i to maxn do write(a[j]); end. var m,n,y:real;b:boolean; begin readln(m,n); b:=false; if m>n then begin y:=m;m:=n;n:=y;b:=true end; if m=0 then begin writeln(0);halt;end; if frac(m/2)<>0 then y:=int(m/2)*4 else y:=int((m-1)/2)*4+2; if b then writeln(y+1:0:0) else writeln(y:0:0); end. #include <stdio.h> #include <math.h> int main(void) { unsigned int n, m, answer; scanf("%u %u", &n, &m); if (m >= n) answer = 2 * (n - 1); else answer = 2 * (m - 1) + 1; printf("%u\n", answer);
return 0; } Ok, same solution after some thinking. And it is working, just remember about huge numbers you are getting in the input #include <iostream> using namespace std; int main() { long long nN, nM; cin >> nN >> nM; if(nM >= nN) cout << 2*(nN-1); else cout << 2*(nM-1)+1; return 0; } Edited by author 12.11.2008 20:43 Edited by author 12.11.2008 20:44 Shortest sol (C language): main() { unsigned n, m; scanf("%u%u", &n, &m); printf("%u", n <= m ? 2 * n - 2 : 2 * m - 1); } #include <iostream> using namespace std; long long n,m; int main() { cin>>n>>m; if (m>=n) cout<<2*(n-1); else cout<<2*(m-1)+1; } My Solution program Ural1224; var n,m:int64; begin readln(n,m); if n<=m then writeln(n shl 1-2) else writeln(m shl 1-1); end. import java.io.*; import java.util.*; public class www { public static void main(String[] args) throws IOException{ PrintWriter out = new PrintWriter(System.out); Scanner in = new Scanner(System.in); long n = in.nextInt(); long m = in.nextInt(); out.println(m>=n ? 2*n-2 : 2*m-1); in.close(); out.close(); } } Edited by author 27.08.2013 23:07 ee munaqa bo'mag'ur masalaga bosh qotirish shartmi? При компиляции примера выдает ответы такие как указаны в примере. Но при добавлении на сайт выдает ошибку. Не могу понять почему. Подскажите пожалуйста в чем проблема? import java.io.*; import java.math.BigDecimal; public class SqrtDif {
public static void main(String[] args) throws IOException { new SqrtDif().run(); }
PrintWriter out;
void run() throws IOException { out = new PrintWriter(new OutputStreamWriter(System.out)); byte bKbd[] = new byte[256]; int iCnt = 0; String szStr; try { iCnt = System.in.read(bKbd); } catch (IOException ex) { System.out.println(ex.toString()); } szStr = new String(bKbd, 0, iCnt); String[] Str = szStr.trim().split("\\D+"); double dStr; int i = Str.length-1; while (i>=0) { dStr = Double.parseDouble(Str[i]); BigDecimal bigDecimal = new BigDecimal(Math.sqrt(dStr)); bigDecimal = bigDecimal.setScale(4, BigDecimal.ROUND_HALF_UP); out.print(bigDecimal.toPlainString()+"\r"); i--; } out.flush(); } } I got WA#22. What is possible problem here? Precision issues are quite possible in this problem - so, try to solve it in integer numbers. But I saw AC solution in double without epsilon :) If you're quite lucky or tests are weak - it is possible, but anyway quite risky on the real contest. |
|