Common Board Edited by author 28.10.2017 19:36 I test all case in discussion,but all answers right... Can someone help..Thanks!!! ...solved... one test case: 8 1 1 0 0 1 0 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 answer: 3 It's working for me but still WA3 I know how to construct larger cases when knowing solution n<=11&&m<=11,but brute_force for small tests is tooooooooo slow.. d = {'._.\n|.|\n|_|': 0, '...\n..|\n..|': 1, '._.\n._|\n|_.': 2, '._.\n._|\n._|': 3, '...\n|_|\n..|': 4, '._.\n|_.\n._|': 5, '._.\n|_.\n|_|': 6, '._.\n..|\n..|': 7, '._.\n|_|\n|_|': 8, '._.\n|_|\n._|': 9 } 7589535 - Accepted 7590680 - Топ среди Питона 3 по использованию памяти) #include<stdio.h> #include<math.h> int main() { int i,sum=0,n; scanf("%d",&n); if(abs(n)<=10000){
if(n<0){
for(i=1;i>=n;i--){ sum+=i; } } else{ sum=((n*n)+n)/2; } printf("%d",sum);} return 0; } Your code is almost okay.It's wrong only for one test case. When n=0 then according to your code output will be 0.But right answer is 1. Please check again output condition of this problem. Otherwise https://ideone.com/Q6C1gh#include <stdio.h> #include <stdlib.h> int main() { int a,p=0,i,*b; float f,s=0; scanf("%d",&a); b=(int *)malloc(sizeof(int)*a); for(i=0;i<a;i++){ scanf("%d",&b[i]);} /*if (b[i]<3||b[i]>5) scanf("%d",&b[i]); }*/ for(i=0;i<a;i++) s+=b[i]; f=s/a; for(i=0;i<a;i++) { if(b[i]==3){ p=1;} } if(f==5) {printf("Named"); } else if(f>=4.5&&p==0){ printf("High"); } else if(f<4.5&&p==0){ printf("Common");} else {printf("None");} free(b); return 0; } I've passed all of the user tests on here, and any test I can think of. Still getting WA on #14. Here's my non-working code. import java.io.*; public class P1998 { static StreamTokenizer in; static PrintWriter out;
static int nextInt() throws IOException{ do{ in.nextToken(); }while(in.ttype != StreamTokenizer.TT_NUMBER); return (int)in.nval; }
public static void main(String[] args) throws IOException{ in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out);
int n = nextInt(); int m = nextInt(); int k = nextInt();
int[] stones = new int[n]; int[] dropsTo = new int[n];
int tmp = 0, j = 0; for(int i = 0; i < n; i++){ stones[i] = nextInt();
while(j < i - 1 && tmp - stones[j] > k){ tmp -= stones[j]; j++; } tmp += stones[i]; dropsTo[i] = j; }
j = 0; int moment, time = 0; for(int i = 0; i < m; i++){ moment = nextInt() - time; time += moment; j += moment - 1; if(j >= n){ time -= moment - n; j = n; break; } j = dropsTo[j]; }
out.println(time + n - j); out.flush(); } } Create an array of Boolean elements. Size = billion. For i:=1 to n {{ introduce a variable; element of array with index [variable] equals true }} For i:=1 to m {{ introduce a variable; if element of array with index [variable] equals true then increase the counter }} And finally, we output counter)) That's all), sorry for bad english But this solution takes 58 mb of memory... (( Edited by author 06.04.2014 16:17 Then, your code is just using a hash table method. But I check the solution rating, someone can do it in 0.015, and many persons do it below 0.1. How can they do that? Is because that compiler different? Then, your code is just using a hash table method. But I check the solution rating, someone can do it in 0.015, and many persons do it below 0.1. How can they do that? Is because that compiler different? It's not that hard to do it under 0.1 with C. Decent hash implementation and optimized input reading (scanf is too slow!) will actually do the 0.031 trick. 0.062 is achievable with a binary search. I achieved 0.015 by optimizing things speedwise a bit more and using as much memory as was allowed. (studied just for fun a bit how slightly different schemes perform, have to try a few more ideas later, my current 0.015 solution is far from the optimum.) Used Sieve to generate primes till 10^6, and then used those primes to generate larger primes. counted all such numbers satisfying L <= p^(q-1) <=R where p & q are primes (q>2). Subtracted it from R-L+1 How to optimize? I got WA on test 4, but on all tests I could make myself and also on those, which were in the problem, my program answered correctly. Please, suggest some tests, that could help. import java.util.Scanner; import java.util.Stack; public class ReverseRoot_SplitDecimal {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in); Stack<Integer> integerNumberStack = new Stack<Integer>(); Stack<Short> floatingNumberStack = new Stack<Short>();
Double tempDouble = new Double(0);
while(sc.hasNextInt()) { tempDouble = Math.sqrt(sc.nextDouble()); integerNumberStack.push(Integer.parseInt(String.format("%.4f", tempDouble).split("\\.")[0])); floatingNumberStack.push(Short.parseShort(String.format("%.4f", tempDouble).split("\\.")[1])); }
while(!integerNumberStack.isEmpty()) { System.out.printf("\n%d.%04d", integerNumberStack.pop(), floatingNumberStack.pop()); } System.out.println();
sc.close(); } } Just drawing different patterns on paper for several hours and the solution will come! thx, I try 4 days, and accepted 0.031 s. !!!! kostan3@yandex.ru get AC by Divide and Conquer?? is there idea more simple?? My solutions in the two languages produce the same output on my tests. However, the Go version gets WA1. Please fix this. #include<iostream> #include <stdio.h> #include <stdlib.h> #include <string> using namespace std; int main() { long l; string a,b; cin>>a; l=a.length(); if((l>=10)&&(l<=189)) { b=a.substr(l-2,2);
} else if((l>=190)&&(l<=2700)) b=a.substr(l-3,3); else if((l<=2701)&&(l<=36000)) b=a.substr(l-4,4); else b=a.substr(l-5,5); cout<<"//CPP"<<endl; cout<<"#include<iostream.h>"<<endl; cout<<"int main()"<<endl; int i = atoi(b.c_str()); cout<<"{for(int i=1;i<"<<i+1<<";i++)cout<<i;return 0;}"; return 0; } Give me this test My solution give correct answer on all test in topic WA test 7, but i have WA test 5 from judge system. 12 1 2 3 4 2 1 5 8 9 2 10 6 Correct answer: 1 2 10 6 8 1 2 3 4 5 2 3 6 answer: 1 2 3 6 Edited by author 25.10.2017 18:58 Edited by author 25.10.2017 07:16 ... Edited by author 25.10.2017 12:47 The following code: cin>>n; for(i=1;i<=n;i++) { cin>>x[i]>>y[i]; assert(x[i]>=1 && x[i]<=10 && y[i]>=1 && y[i]<=10); here[x[i]][y[i]]=true; } gives RTE, so test 2 is wrong. After, removing the assert, it gives WA :) Input One representation of the image will be given to your program in the input. Output Your program has to write other representation of the image to the output. The following code: cin>>n; for(i=1;i<=n;i++) { cin>>x[i]>>y[i]; assert(x[i]>=1 && x[i]<=10 && y[i]>=1 && y[i]<=10); here[x[i]][y[i]]=true; } gives RTE, so test 2 is wrong. After, removing the assert, it gives WA :) TEST 2 like this : Input: 2 3 RT, RT, , B, , . Output: 6 2 3 2 4 3 3 3 4 4 2 4 3 |
|