| Show all threads Hide all threads Show all messages Hide all messages |
| Who knew Test 11, my program always WA? | xurshid_n | 1147. Shaping Regions | 8 Mar 2010 21:36 | 1 |
this my code: import java.io.*; import java.util.*; public class Problem_1147 implements Runnable{ public static void main(String []args){ new Thread(new Problem_1147()).start(); } public void run(){ try{ reader = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); //reader = new StreamTokenizer(new BufferedReader(new FileReader("card.out"))); //out = new PrintWriter(new FileWriter("card.out")); solve(); }catch(IOException e){ throw new IllegalStateException(e); } }
final int COLOR_COUNT = 5501; final int N = 400001; int n; int width; int height;
int xPos[] = new int[10001]; int yPos[] = new int[10001];
int color[] = new int[COLOR_COUNT]; int x[] = new int[1001]; int y[] = new int[1001]; int z[] = new int[1001]; int t[] = new int[1001]; int cc[] = new int[1001]; int xc[] = new int[1009]; int yc[] = new int[1009];
short tColor[][] = new short[2002][2002];
StreamTokenizer reader;
PrintWriter out;
int nextInt()throws IOException{ reader.nextToken(); return(int)reader.nval;
}
void solve()throws IOException{
width = nextInt(); height = nextInt(); n = nextInt();
for (int i = 1; i<=n;i++){ x[i] = nextInt(); y[i] = nextInt(); z[i] = nextInt(); t[i] = nextInt();
cc[i] = nextInt(); } x[0] = 0; y[0] = 0; z[0] = width; t[0] = height; cc[0] = 1;
Arrays.fill(xPos,0); Arrays.fill(yPos,0);
for (int i = 0;i <=n ;i++)xPos[x[i]] = xPos[z[i]] = yPos[y[i]] = yPos[t[i]] = 1;
for (int i = 1; i<= width; i++)xPos[i] += xPos[i-1]; for (int i = 1; i<= height; i++)yPos[i] += yPos[i-1];
for (int i = width; i >= 0 ; i-- ) xc[xPos[i]] = i ; for (int i = height; i>= 0 ; i-- ) yc[yPos[i]] = i ;
/* System.out.println("x coords "); for (int i = xPos[0] ; i<=xPos[width];i++)System.out.println(xc[i]); System.out.println("y coords "); for (int i = yPos[0] ; i<=yPos[height];i++)System.out.println(yc[i]); */ for (int i = 0; i<=n;i++){ int i_x = xPos[x[i]]; int j_x = xPos[z[i]]; int i_y = yPos[y[i]]; int j_y = yPos[t[i]]; short c = (short)cc[i]; // System.out.println(i_x +" " +j_x+" " +i_y+" " +j_y); for (int v = i_x; v < j_x; v++){ for (int w = i_y; w < j_y; w++){ tColor[v][w] = c; } } }
Arrays.fill(color, 0); for (int i = xPos[0]; i < xPos[width]; i++){ for (int j = yPos[0]; j < yPos[height]; j++){ color[tColor[i][j]] += (xc[i+1] - xc[i])*(yc[j+1] - yc[j]); } }
for (int i = 1; i<=2500;i++)if (color[i]>0)System.out.println(i+ " "+color[i]); }
} |
| Why WA on #3 | cz908640443 | 1001. Reverse Root | 8 Mar 2010 14:04 | 2 |
var i,j,k,l,m:longint; n:qword; a:array[1..10000000]of qword; q:double; begin n:=0; while not eof do begin inc(n); read(a[n]); end; for i:=n-1 downto 1do begin writeln(sqrt(a[i]):0:4); end; end. I finally found where I did wrong... var i,j,k,l,m:longint; n:qword; a:array[1..10000000]of qword; q:double; begin n:=0; while not seekeof do begin inc(n); read(a[n]); end; for i:=n downto 1do begin writeln(sqrt(a[i]):0:4); end; end. should use "seekeof" instead of "eof" |
| What answer? | Vit Demidenko | 1750. Pakhom and the Gully | 8 Mar 2010 00:04 | 4 |
What answer for this test? 0 0 8 0 2 0 4 0 6 0 Thank you, and what answers for this test? 3 1 1 4 4 0 3 3 3 3 0 0 0 0 4 2 1 0 2 2 3 0 0 0 4 0 2 2 2 3 2 |
| What is the tricky part of this problem? Any hint please...WA on #4 | Danica Porobic | 1037. Memory Management | 7 Mar 2010 20:08 | 5 |
I've tried to solve this problem, using simple aproach, only one array in which i remember time until that part of the memory is allocated. On request I check if it's used, if is shift time to new value if not nothing change... On new allocation I search for the first free memory spot... Very simple, straight from the text, but I get WA on #4. Could someone post some tricky test or explain why my algorithm is wrong? Thank you very much! I wouldn't say that it was very easy, but I got AC and learn new way of programming. Try this test: 64999 + 65000 . 1 --------- 1 + |
| Time limit exceeded. Help! (Java) | Lendon | 1001. Reverse Root | 7 Mar 2010 18:59 | 3 |
I don't know how to correct my program for more speedly work. Help anybody. import java.util.*; import java.math.*; public class InvertedSqrt { public static void main(String []args) { Scanner scan = new Scanner(System.in); ArrayList<BigInteger> input = new ArrayList<BigInteger>(); input.add(scan.nextBigInteger()); while(scan.hasNextBigDecimal() && input.size() * Integer.SIZE <= 256 * 1024 * 1024) { input.add(scan.nextBigInteger()); } scan.close(); int i = input.size() - 1; while(i >=0) { System.out.printf("%.4f",java.lang.Math.sqrt(input.get(i).doubleValue())); System.out.print("\n"); i--; } } } in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(new OutputStreamWriter(System.out)); I don't know how to correct my program for more speedly work. Help anybody. import java.util.*; import java.math.*; public class InvertedSqrt { public static void main(String []args) { Scanner scan = new Scanner(System.in); ArrayList<BigInteger> input = new ArrayList<BigInteger>(); input.add(scan.nextBigInteger()); while(scan.hasNextBigDecimal() && input.size() * Integer.SIZE <= 256 * 1024 * 1024) { input.add(scan.nextBigInteger()); } scan.close(); int i = input.size() - 1; while(i >=0) { System.out.printf("%.4f",java.lang.Math.sqrt(input.get(i).doubleValue())); System.out.print("\n"); i--; } } } use double, but not BigInteger |
| Problems with comparator | wRabbits_AlMag(VNTU) | | 7 Mar 2010 15:39 | 4 |
Hi. I'm using :) such a construction in my code struct maxY { bool operator () (const int& n1, const int& n2) { // compare something } }; ... set<int, maxY> s; in my VS 2009 it's ok, but Online Judge says it's a compilation error. Help to fix, please. Oh, yeah, thanks :) Any other thoughts? I've got, what's the problem. bool operator()(int t1, int t2)const { ... } should be written |
| test 5????? | zsyzhbc_china | 1712. Cipher Grille | 7 Mar 2010 10:41 | 1 |
|
| check this test please | sich_off (ONPU) | 1600. Airport | 7 Mar 2010 02:19 | 2 |
I have WA 3. what should i output for this test? 2 1 1.000000000001 0 0 0 0 0 0 0 0 -1 0 0 |
| One more test | Fyodor Menshikov | 1146. Maximum Sum | 6 Mar 2010 20:11 | 4 |
Please add the following test: N=100, the following 10000 numbers -127. Awhile there is no test where answer is negative. Thank you. New tests were added, and many authors lost AC. |
| To all C++ coders having problems with T#3 or so... | Intelligent_Design | 1294. Mars Satellites | 6 Mar 2010 17:33 | 3 |
In this problem,rounding the double value to the nearest integer appeares to be the most tricky part of the whole problem. If you want to guarantee correct rounding, do it yourself with floor() and ceil(). At least,as it happened to me.:) You can do it like this: printf("%.0lf\n", res); You are absolutely right: ``cout << int(r)'' is WA, while ``printf("Distance is %.0lf km.", r);'' is AC. |
| Could V[i] be negative? | bsu.mmf.team | 1541. Chase | 6 Mar 2010 14:05 | 1 |
Edited by author 14.05.2010 21:41 |
| Test 2# | Element | 1010. Discrete Function | 6 Mar 2010 13:35 | 2 |
Just change longint into int64. Oh,my god! Don't the author say all values are longint? |
| Hint | ASK | 1497. Cutting a Square | 6 Mar 2010 01:57 | 2 |
Hint ASK 6 Mar 2010 01:52 It is not necessary a rectangle. Try 5 11111 11011 11011 10010 00000 Yes and all its rotations. BTW, to read you can use #define F(i,n) for(int i = 0; i < n; ++i) int n; vector<string> s; [...] cin >> n; s.resize(n, string(n,' ')); F(i,n) cin >> s[i]; and AC at 0.046 second. ... whereas F(i,n) { string str; cin >> str; s.push_back(str); } results in 0.109 seconds and 500 KB of wasted memory. |
| What's the 8th test? | MeLodyloveyr | 1730. ManBearPig | 5 Mar 2010 07:12 | 1 |
I always crash on that test...float point wrong |
| Hint | Yegor Suvorov | 1601. AntiCAPS | 5 Mar 2010 02:27 | 2 |
Hint Yegor Suvorov 23 May 2008 19:50 Correct answer for this test: ---------- iT is HinT ---------- is ---------- It is hint ---------- No. This test no correct. He does not qualify under the condition of the problem. Edited by author 05.03.2010 02:28 |
| Why is WA for Test 9? Pls. Help me. | logic | 1001. Reverse Root | 4 Mar 2010 12:59 | 9 |
#include<stdio.h> #include<math.h> int main() { double a[100000]; signed long int i = 0; while (scanf("%lf", &a[i]) != EOF) { i++; } i--; while ( i >= 0) { printf("%.4lf\n",sqrt(a[i])); i--; } return ; } !!!!!EXTENDED for Pascal!!!!!! !!!!!LONG DOUBLE for C++!!!!!! try this: double a [128*1024] use dinamic memory try double *a = (double *) malloc (sizeof(double)*128*1024); and when you done before return free (a); thats all :) Aleksa_Markoni, thank you! Could you tell me why it should use dinamic memory ? Thank you! There is no need to use dinamic memory ... Just make sure that your array is large enough. But I wonder why the result I get is TLE ... this is my code: #include<stdio.h> #include<string.h> #include<math.h> double a[100010];//make it larger and then I got AC int main() { int k=0; while(scanf("%lf",&a[k])!=EOF)k++; while(k) printf("%.4lf\n",sqrt(a[--k])); return 0; } use dinamic memory try double *a = (double *) malloc (sizeof(double)*128*1024); and when you done before return free (a); thats all :) Edited by author 21.10.2009 00:40 while your program submit it replies Time limit exceeded for what reason? |
| WA#29 | Hatred | 1464. Light | 4 Mar 2010 00:17 | 2 |
WA#29 Hatred 4 Mar 2010 00:12 What it could be? Any tests please. Well, after I started to use double instead of float, it passed the test. |
| Problem with 8 is... | Hanzbrow (TNU) KCC | 1423. String Tale | 3 Mar 2010 21:31 | 4 |
Why I've got MLE(19 MB). I use KMP and I don't understand why at all! I appeal to you for help... #include<iostream> #include<string> #include<vector> using namespace std; int main() { int i, j, f=0, n; string what_to_find, gde; cin>>n>>what_to_find>>gde; what_to_find+="#"; what_to_find+=gde; what_to_find+=gde; gde=""; vector<short> next(what_to_find.size()); next[0]=0; for(i=1; i<what_to_find.size(); i++){ if(what_to_find[i]==what_to_find[next[i-1]]) next[i]=next[i-1]+1; else { j = next[i-1]; while (j>0 && what_to_find[i]!=what_to_find[j]){ j=next[j-1]; if(what_to_find[i]==what_to_find[j]) next[i]=j+1; } } if(next[i]==n) { f=1; break; } } if(f) cout<<i-2*n; else cout<<-1; return 0; } When I was using strings,I had MLE 8. Bit in my AC programm I used arrays of char. I get MLE#8 too, using std::string but my AC program with arrays uses only 4.4 MB... Admins, can you please explain such strange behaviour of the judge system? Try to preallocate strings: int n; cin >> n >> ws; string str(n,' '); getline(cin, str); |
| Mistake in statement | Fyodor Menshikov | 1417. Space Poker 2 | 3 Mar 2010 19:30 | 3 |
подсмотренная ими у каких подвыпивших космонавтов -> подсмотренная ими у каких-то подвыпивших космонавтов |
| Java vs MLE | unlucky [Vologda SPU] | 1287. Mars Canals | 3 Mar 2010 19:19 | 2 |
If you use Java pay attention to size of arrays, that you used. I used 2 arrays for saving current line and prev line of input(every has o(n) elements), and 2 arrays for saving result of calculating in prev Line, and for saving result of calculation in current line (every has o(n) elements). Edited by author 21.02.2010 15:56 This problem is not so memory consuming. Java solution using variable char field[][] = new char[1 + n + 1][1 + n + 1]; gets AC. So it is possible to store whole input in memory, but it is impossible to store significant amount of data for each cell. For example 4 arrays NxN of 16-bit ints need extra 16 Mb of memory while total ML is 16 Mb. |