Common BoardI cannot pass test10 and i cannot find any mistakes. Is my algo wrong? my code: program p1490; var   r,n:int64;   i:longint;   x:real; begin   readln(r);   for i:=r-1 downto 0 do     begin       x:=sqrt(sqr(r)-sqr(i));       if x-trunc(x)<1e-10         then inc(n,r-trunc(x))         else inc(n,r-trunc(x)-1);     end;   writeln(4*(r*r-n)); end. I have got AC! I changed "sqr(r)-sqr(i)" into "(r+i)*(r-i)". Then I don't WA#10 any more, but I don't know why. Could anyone tell me? Sorry for my poor English... Overflow of type.   Edited by author 30.07.2012 20:16   Edited by author 30.07.2012 20:17 uses std::nth_element My solution takes 15 lines of code :) And it is possible to do fewer. Did you use Linear time majority vote algorithm? I have WA#3ю Please give me test #pragma comment(linker,"/STACK:1000000000,1000000000") I think, this problem requires that; right?   Any method description or link to article is really appreciable Thanks in advance. the distance between any pair of computer must greater than one, not between two pair which connect whit cable.   sorry for my poor english. GOOD LUCK!!!   Edited by author 06.12.2010 20:26   Edited by author 06.12.2010 20:26 6 1 999999998 b 1 2 b 2 3 w 4 5 b 5 6 w 6 7 b   ans: 999999998 1000000000     Do you understand? if both players get stuck and after shooting their rockets still stuck?   or is infinite game scenario like 'stalemate' is possible? like   2 ...... .*..2. ...... ...... .1.... ......   Here, if 1 makes turn 2 wins by killing; same goes for 2. now, would they infinitely 'pass moves' to lead it to a 'Draw' / stalemate? or the ans is 'Lose'?   Please, help me understand the problem? Thanks in Advance. if (state[IND(start)] == 'N') printf("Draw\n"); Sorry, didn't understand you :( Can you give a bit more detail? they will infinitely pass moves, so answer is Draw Hi! My program got output for test1 (011010011): 5 back 0 double double double front 1   --------------------------------------- ''-> 0 -> 01 -> 0110 -> 01101001 -> 011010011   It's right?   Upd: I found bug in my program, and fixed it, AC!   Edited by author 28.07.2012 17:59 #include<iostream> #include<stdio.h> using namespace std; int main() {char c[200000],d; int i=0,j,k; while(cin>>c[i]&&i<200000) {char d=c[i]; if(i!=0&&c[i-1]==d){c[i]=c[i-1]=NULL;i=i-1;} else if(int(d)==32){c[i]=NULL;} else i++; }   cout<<c<<endl; return 0; }     Edited by author 20.07.2012 19:31 Length is 200000, not 20000 still got wa@9 please help Length is 200000, not 20000 Hi guys I can't recognize what I've done wrong:   #include <cstdlib> #include <iostream> #include <string> #include <sstream>   using namespace std;   int main(int argc, char *argv[]) {     int b,c,d,k,n,a[99],TrafficJam=0;     string line1, line2, line1p, line2p, sk, sn, sa[99];     size_t pos,pos1[99];     do     {            cout<<"Give first line"<<endl;            getline (cin,line1);            pos=line1.find(" ");            sk=line1.substr(0,pos);            line1p=line1.substr(pos+1);            pos=line1p.find(" ");            sn=line1p.substr(0,pos);            if ( !(istringstream(sk) >> k) ) k=0;            if ( !(istringstream(sn) >> n) ) n=0;     }     while ( ( sk.size() + sn.size() + 1 ) != line1.size() || k < 1 || k > 100 || n < 1 || n > 100);     do     {           b=0;           d=-1;           cout<<"Give second line"<<endl;           getline (cin, line2);           line2p=line2;           for (int i=0;i<n;i++)           {               pos1[i]=line2.find(" ");               sa[i]=line2.substr(0,pos1[i]);               line2=line2.substr(pos1[i]+1);               istringstream(sa[i]) >> a[i];               d+=sa[i].size()+1;               if (a[i]<0 || a[i] > 100) b++;           }     }     while (b!=0 || d!=line2p.size() );     for (int i=0;i<n;i++)     {         TrafficJam=TrafficJam+a[i]-k;         if(TrafficJam<0)         TrafficJam=0;     }     cout<<TrafficJam<<endl;     system("PAUSE");     return EXIT_SUCCESS; }   Everything works, but still wrong answer test #1. Can you help? I've tried to find sth for many times, without success. remove this - cout<<"Give second line"<<endl; and this -  cout<<"Give first line"<<endl;     Edited by author 27.07.2012 05:01 ok thanks it works :D. Why should I did that? Can't I add anything what only helps? Testing system doesn't think that answer   Give first line Give second line 0   is right.   It thinks that answer   0   is right.   Edited by author 27.07.2012 16:01   Edited by author 27.07.2012 16:01 Finally, I found the way to solve it in O(n) (needs about 4 full string-checks). In journey to this solution i tried to imagine that i'm cutting brackets like '()'. And watching what I can get by cutting all this pieces. Looking on new sequence I understood what I need to shift to get right bracket-sequence.   Here are some tests that helped me:   )))(()(( ans: 1   (()(())) ans: 1   ())( ans: 1   ))(())())((()( ans: 1   Edited by author 27.07.2012 14:19 what is the test #7? I have tried my own tests, my program outputs right answers, i don't know what to do try this: 2 A B C Isenbaev A D   answer is:   A 1 B 2 C 2 D 1 Isenbaev 0 Can anybody give me some tests? Time interval for each mage is not [t, s], it is [t, t+s-1]. it's all about point in tests (maybe) are nubmers in format XX.YYY I have WA#2 try test   3 0 0 0 0 0 0 0 0 0  |  
  |