Общий форум for the range 1 to 2^31-1 even O(n) soln won't work i.e even a single loop will take more time if we want to use f(n,m) = abs(f(1,n)-f(1,m)) we need to store 2^31 values... how is it possible to store so many numbers!!!!
You don't need to store so many numbers. Tey to find another way (try to see how change length between fixed nodes). f(n,m) = abs(f(1,n) - f(1,m)) - it's ok. why get 'ac' used ""pascl"" var n:int64; begin readln(n); writeln(n*n); writeln(n); end. --------------------------------- but: #include<stdio.h> int main() { unsigned long long n; scanf("%lld",&n); printf("%lld\n",n*n); printf("%lld\n",n); return 0; } who could tell me when i use "c",get "wa"? i am confused;
read FAQ for long long you should use %I64d if send : var n:longint; begin readln(n); if n=5 then while true do begin end; end. we get TLE but if send all this file's begin writeln(0); end. begin writeln(1); writeln(1);end. begin writeln(1); writeln(2);end. begin writeln(1); writeln(3);end. begin writeln(1); writeln(4);end. begin writeln(1); writeln(5);end. begin writeln(2); writeln(1);writeln(2);end. begin writeln(2); writeln(2);writeln(3);end. begin writeln(2); writeln(3);writeln(4);end. begin writeln(2); writeln(4);writeln(5);end. begin writeln(3); writeln(1);writeln(2);writeln(3);end. begin writeln(3); writeln(2);writeln(3);writeln(4);end. begin writeln(3); writeln(3);writeln(4);writeln(5);end. begin writeln(4); writeln(1);writeln(2);writeln(3);writeln(4);end. begin writeln(4); writeln(2);writeln(3);writeln(4);writeln(5);end. begin writeln(5); writeln(1);writeln(2);writeln(3);writeln(4);writeln(5);end. all this submit return WA1!!! how it posible???? Be attentive. You should print not indices but numbers themselves. For example, for input 5 1 1 1 1 1 you should output 5 1 1 1 1 1, not 5 1 2 3 4 5. omg!!! thanks. this task so old that i remember it from time when it 1st time was published, than so silly my mistake Ж) subj You solved this problem... Help me PLEASE!!!!!!!!!! I got WA8 too.. +( #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> char *text; bool dpp=true; void comments();/* (* Comments *) */ void alu(); /* (1+2+3(5+6+7)) */ void mloop() { while(*text&&dpp) {
if(text[0]=='(') { if(text[1]=='*') { text+=2; comments(); continue; } else { text+=1; alu(); continue; }
} text++; } } void alu() { while(1) { if(text[0]==')') { text+=1; return; }
else { if(text[0]=='(') { if(text[1]=='*') { text+=2; comments(); continue; } else { text+=1; alu(); continue; } } else {
if((text[0]==' ')||(!isdigit(text[0])&&*text!='+'&&*text!='-'&&*text!='*'&&*text!='/'&&*text!='='&&*text!='\n'&&*text!='\r') ) {
dpp=false; return; } } } text++; } } void comments() { while(*text) { if(text[0]=='*') { if(text[1]==')') { text+=2; break; } } text++; } if(!*text)dpp=false; } int balans()/* Test for '(' and ')' */ { int k=0,n=0; while(*text) { if(*text=='(') { text++; if(*text=='*') { text++; comments(); if(dpp==false)return 1; continue; } else {k++;continue;} } else { if(*text==')') n++; } text++; } if (k==n) return 0; else return 1; } int main() { char *txt2,*txt3; text=(char*)malloc(10001); txt3=(char*)malloc(501); memset(txt3,0,sizeof(txt3)); memset(text,0,sizeof(text)); while(!feof(stdin)) { fgets(txt3,500,stdin); strcat(text,txt3); memset(txt3,0,sizeof(txt3));
} txt2=text;
if(balans()==0) { text=txt2;
mloop(); if(dpp) printf("YES"); else printf("NO"); } else printf("NO"); } It's my code... It's not clear... But it work on all test which i found on this discuss...What can be on #8 ? +( You should change this: void comments() { while(*text) { if(text[0]=='*') { if(text[1]==')') { text+=2; return; } } text++; } dpp=false; } Please add this test: 3 3 2 2 2 2 the ans is YES while my prev Accept program got No.Now I fix the bug but I'm sure that several Accepted author will lost AC > Just insert numbers to the binary tree and then print them in the order you want. > > > rubbish! Yeah!! Try to see structure of input and output strings. Resursion-recursion. program timus1136a; {$APPTYPE CONSOLE} uses SysUtils; const mz=100000; var a,b:array[0..3000] of longint;n,i,p,q:longint; procedure f(u,r,t:longint);begin if(a[u]<r){l} then begin p:=u;exit;end; f(u-1,a[u],t); f(p,r,a[u]); inc(q);b[q]:=a[u];if u<=p then p:=u-1; end; begin read(n); for i := 1 to n do read(a[i]);a[0]:=-1; p:=n;q:=0; f(n,0,mz); for i := 1 to n-1 do write(b[i],' ');write(b[n]);
end. ?????can any1 help me????? thanks. If there are some lines in your program like this: s:string; For i:=0 to length(s) do s[i].... good luck! Why I got WA on test #1 ? My program works correctly for all the test I've found on this forum! What is test #1 ? Please help or I'll become a crazy man! Can anybody explain me why such a construction as (**) must be understood by my program as not correct? According to my mind, this construction is an empty comment. So, why it isn't a correct construction? Sorry, this construction is correct, I've been disappeared by one of topics in this forum. Topic is closed. P.S. Sorry for my English. As I understand the user can use new line to seperate the numbers, but how can we know which "Enter" is the last one (or the input stream ends) ? See FAQ. Thanks. Any examples for C# ? And example for Java, plz Read with Console.Read() char by char. When the end of input stream was reached method returns -1. Read with Console.Read() char by char. When the end of input stream was reached method returns -1. Will Reader.read() in Java have the same effect? Java : while((line = f.readLine()) != null) { ... } ?? I tried that and it didnt work... the program never stops... Does anybody know how to stop the infinite loop? Also, you can use Console.In.ReadToEnd(); WHY TIme limit on 1 test?????????????????????????? program z1027; {$APPTYPE CONSOLE} uses SysUtils; var s,s1:string; flag,flag1,i:integer; begin { TODO -oUser -cConsole Main : Insert code here } {$IFNDEF ONLINE_JUDGE} assign(input, 'input.txt'); reset(input); assign(output, 'output.txt'); rewrite(output); {$ENDIF} while not seekeof do Begin read(s1); s:=s+s1; End; ..... ..... {$IFNDEF ONLINE_JUDGE} close(input); close(output); {$ENDIF} end. Edited by author 01.03.2007 12:38 What does your code fragment mean? "Time Limit" error means that your algo use too much time. Try to find a better algo. P.S. Sorry for my English. Edited by author 01.01.2008 18:34 I have used quick sort algo, but I've got WA#5. Show me this test, please. I can't understand what mistake I've done in my solution. P.S. Sorry for my English. I can't seem to read the end of the input file, how can i fix this? This is my code: import java.io.*; import java.util.*; public class revroot {
public static void main(String[] args) {
Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out);
while (in.hasNextDouble()) { double a = in.nextDouble(); out.println(Math.sqrt(a)); } out.close(); } } Thanks in advance. What output? 150 4 50 50 50 50 and this 200 4 50 50 50 50 My AC program outputs -1 in both cases Why output -1 for the second test??? My output for the first one is -1 and for the second one is an empty line. second test is not valid. it's given that some cards are missing... which means there is atleast one card missing Please, explain, why a man with smallest precision must not shoot before killing one of others, and give me some examples for testing my program |
|