10642 - Can You Solve It?

All about problems in Volume 106. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
sentientfragment
New poster
Posts: 2
Joined: Tue Oct 05, 2004 11:07 pm

10642 - Can You Solve It?

Post by sentientfragment » Tue Oct 05, 2004 11:16 pm

when I submit it, it says wrong answer :(

any ideas?

Code: Select all

// @JUDGE_ID 51586EH 10642 Java "Can you solve it?"

import java.io.*;
import java.util.*;

class Main 
{

	static String ReadLn (int maxLg)
	{
		byte lin[] = new byte [maxLg];
		int lg = 0, car = -1;
		String line = "";

		try
		{
			while (lg < maxLg)
			{
				car = System.in.read();
				if ((car < 0) || (car == '\n')) break;
				lin [lg++] += car;
			}
		}
		catch (IOException e)
		{
			return (null);
		}

		if ((car < 0) && (lg ==0)) return (null);
			return (new String (lin, 0, lg));
	}

	public static void main (String[] args)
	{
		long xa, xb, ya, yb, yc, xc, za, zb, cases, startsubtract=0, loopcnt = 0, moves = 1, casenum = 1;
		String input;
		StringTokenizer idata;

		input = ReadLn (20); 
		idata = new StringTokenizer (input);
		cases = Integer.parseInt (idata.nextToken());

		while (casenum <= cases)
		{
		
			input = ReadLn (20);  
			idata = new StringTokenizer (input);
	
			xa = Integer.parseInt (idata.nextToken());
			ya = Integer.parseInt (idata.nextToken());
			xb = Integer.parseInt (idata.nextToken());
			yb = Integer.parseInt (idata.nextToken());

			xc = xa;
			yc = ya;

			while (yb != 0)
			{
				yb--;
				xb++;
				moves--;			
			}

			zb = xb - 2;
			

		if (xb != 0)
			moves = moves + ((xb - 1)*(xb - 1)/2-zb/2 + (2*xb + zb +1));

			while (ya != 0)
			{
				ya--;
				xa++;
				moves++;
			}

		
			za = xa - 2;
			
			if (xa != 0 && za >= 0)
			{
				moves = moves + 1 - ((xa - 1)*(xa -1)/2-za/2 + (2*xa + zb +1));
			//	System.out.println("za > 0");
			}	
	
			if (za < 0)
			{
				moves = moves - ((xa - 1)*(xa - 1)/2 + (2*xa +1));
			//	System.out.println("za < 0");
			}

			System.out.println("Case "+casenum+": "+moves);
			moves = 1;

			casenum++;
		}
	}
}
I know my code is pretty sloppy...but all the tests I ran seemed to generate the right number, but it says wrong answer.

sentientfragment
New poster
Posts: 2
Joined: Tue Oct 05, 2004 11:07 pm

Post by sentientfragment » Sat Oct 09, 2004 4:40 am

nobody is able to give me any assistance at all...?

Arm.Turbo
New poster
Posts: 21
Joined: Wed Aug 11, 2004 1:20 pm

Post by Arm.Turbo » Wed Oct 13, 2004 4:03 pm

Input:

Code: Select all

100
41 8467 6334 6500
9169 5724 1478 9358
6962 4464 5705 8145
3281 6827 9961 491
2995 1942 4827 5436
2391 4604 3902 153
292 2382 7421 8716
9718 9895 5447 1726
4771 1538 1869 9912
5667 6299 7035 9894
8703 3811 1322 333
7673 4664 5141 7711
8253 6868 5547 7644
2662 2757 37 2859
8723 9741 7529 778
2316 3035 2190 1842
288 106 9040 8942
9264 2648 7446 3805
5890 6729 4370 5350
5006 1101 4393 3548
9629 2623 4084 9954
8756 1840 4966 7376
3931 6308 6944 2439
4626 1323 5537 1538
6118 2082 2929 6541
4833 1115 4639 9658
2704 9930 3977 2306
1673 2386 5021 8745
6924 9072 6270 5829
6777 5573 5097 6512
3986 3290 9161 8636
2355 4767 3655 5574
4031 2052 7350 1150
6941 1724 3966 3430
1107 191 8007 1337
5457 2287 7753 383
4945 8909 2209 9758
4221 8588 6422 4946
7506 3030 6413 9168
900 2591 8762 1655
7410 6359 7624 537
1548 6483 7595 4041
3602 4350 291 836
9374 1020 4596 4021
7348 3199 9668 4484
8281 4734 53 1999
6418 7938 6900 3788
8127 467 3728 4893
4648 2483 7807 2421
4310 6617 2813 9514
4309 7616 8935 7451
600 5249 6519 1556
2798 303 6224 1008
5844 2609 4989 2702
3195 485 3093 4343
523 1587 9314 9503
7448 5200 3458 6618
580 9796 4798 5281
9589 798 8009 7157
472 3622 8538 2292
6038 4179 8190 9657
7958 6191 9815 2888
9156 1511 6202 2634
4272 55 328 2646
6362 4886 8875 8433
9869 142 3844 1416
1881 1998 322 8651
21 5699 3557 8476
7892 4389 5075 712
2600 2510 1003 6869
7861 4688 3401 9789
5255 6423 5002 585
4182 285 7088 1426
8617 3757 9832 932
4169 2154 5721 7189
9976 1329 2368 8692
1425 555 3434 6549
7441 9512 145 8060
1718 3753 6139 2423
6279 5996 6687 2529
2549 7437 9866 2949
193 3195 3297 416
8286 6105 4488 6282
2455 5734 8114 1701
1316 671 5786 2263
4313 4355 1185 53
912 808 1832 945
4313 7756 8321 9558
3646 7982 481 4144
3196 222 7129 2161
5535 450 1173 466
2044 1659 6292 6439
7253 24 6154 9510
4745 649 3186 8313
4474 8022 2168 4018
8787 9905 7958 7391
202 3625 6477 4414
9314 5824 9334 5874
4372 159 1833 8070
7487 8297 7518 8177
Output:

Code: Select all

Case 1: 46171202
Case 2: 52200996
Case 3: 30634467
Case 4: 3543172
Case 5: 40482095
Case 6: 16243459
Case 7: 126640107
Case 8: 166619411
Case 9: 49494074
Case 10: 71706792
Case 11: 76943396
Case 12: 6483893
Case 13: 27324751
Case 14: 10493259
Case 15: 135962796
Case 16: 6188874
Case 17: 161616090
Case 18: 7657520
Case 19: 32383350
Case 20: 12882320
Case 21: 23472318
Case 22: 20021957
Case 23: 8395631
Case 24: 7333986
Case 25: 11217896
Case 26: 84516733
Case 27: 60072836
Case 28: 86521839
Case 29: 54745710
Case 30: 8878860
Case 31: 131906952
Case 32: 17228132
Case 33: 17628083
Case 34: 10194314
Case 35: 42823689
Case 36: 3114972
Case 37: 24365793
Case 38: 17418048
Case 39: 65881562
Case 40: 48174729
Case 41: 61494310
Case 42: 35457617
Case 43: 30988811
Case 44: 16896940
Case 45: 44524070
Case 46: 82603470
Case 47: 45932048
Case 48: 228017
Case 49: 26885119
Case 50: 16277003
Case 51: 63154542
Case 52: 15504444
Case 53: 21348303
Case 54: 6152100
Case 55: 20877624
Case 56: 174830839
Case 57: 29228340
Case 58: 3033498
Case 59: 61059703
Case 60: 50275466
Case 61: 107070127
Case 62: 19412862
Case 63: 17858866
Case 64: 4943747
Case 65: 86530223
Case 66: 36284661
Case 67: 32735032
Case 68: 56044037
Case 69: 58672860
Case 70: 17927926
Case 71: 8245210
Case 72: 52583856
Case 73: 26271983
Case 74: 18625680
Case 75: 63348731
Case 76: 2747443
Case 77: 47875955
Case 78: 110052762
Case 79: 21693968
Case 80: 32871606
Case 81: 32260746
Case 82: 1157179
Case 83: 45559599
Case 84: 14643724
Case 85: 30426617
Case 86: 36807633
Case 87: 2378113
Case 88: 87005853
Case 89: 56916546
Case 90: 37317557
Case 91: 16573487
Case 92: 74191838
Case 93: 96206178
Case 94: 51567376
Case 95: 58947171
Case 96: 56902032
Case 97: 51993783
Case 98: 1062165
Case 99: 38769871
Case 100: 1400829

guayoyo
New poster
Posts: 11
Joined: Wed Aug 17, 2005 5:59 pm
Location: Caracas, Venezuela

All your test cases are correct, but what is the answer...

Post by guayoyo » Fri Sep 23, 2005 8:14 pm

Hi everybody! I tried Arm.Turbo test cases, and everyone is correct, but what should be the answer for this case:
3
0 0 0 0
1 1 1 1
0 1 1 0
Thanks everyone in advance...
10024 - Guayoyo has Curled Up the Cube!

User avatar
Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Re: All your test cases are correct, but what is the answer.

Post by Martin Macko » Sat Sep 24, 2005 12:27 am

guayoyo wrote:Hi everybody! I tried Arm.Turbo test cases, and everyone is correct, but what should be the answer for this case:
3
0 0 0 0
1 1 1 1
0 1 1 0
Thanks everyone in advance...
The answer is

Code: Select all

Case 1: 0
Case 2: 0
Case 3: 1

guayoyo
New poster
Posts: 11
Joined: Wed Aug 17, 2005 5:59 pm
Location: Caracas, Venezuela

Finally

Post by guayoyo » Tue Sep 27, 2005 10:57 pm

Thanks, I got AC...
10024 - Guayoyo has Curled Up the Cube!

sazzadcsedu
Experienced poster
Posts: 136
Joined: Sat Nov 29, 2008 8:01 am
Location: narayangong,bangladesh.
Contact:

10642:can u solve it(presentation error)

Post by sazzadcsedu » Wed Dec 17, 2008 8:52 pm

i got PE;

anyone can help??
my code.

Code: Select all

 
                      #include<stdio.h>


                        int main()
  


						 {   
				                   int x1,y1,x2,y2;

							  int index1,index2;
                                           int n,i;

							 i=1;
							 

							 scanf("%d",&n);
                            
							 while(i<=n)

							 {

							 scanf("%d %d %d %d",&x1,&y1,&x2,&y2):
                                                        index1=((1+(y1+x1))*(y1+x1))/2 +x1;
							 //printf("%d\n",index1 );

							 index2=((1+(y2+x2))*(y2+x2))/2 +x2;

                                                        //printf("%d\n",index2);

							 printf("Case %d:%d\n",i,index2-index1);

                                                        i++;
						       }
                                                       return 0;

						   } 
Life is more complicated than algorithm.
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com

newkid
Learning poster
Posts: 73
Joined: Fri Dec 12, 2008 3:06 am

Re: 10642:can u solve it(presentation error)

Post by newkid » Wed Dec 17, 2008 9:09 pm

Code: Select all

printf("Case %d:%d\n",i,index2-index1);
The should be a space between the colon and the result..

Code: Select all

printf("Case %d: %d\n",i,index2-index1);
cheers
hmm..

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

10642 - Can You Solve It?

Post by saiful_sust » Fri May 29, 2009 11:11 am

sazzadcsedu
sazzadcsedu
PLZ remove ur code after ACC
:roll:

User avatar
plamplam
Experienced poster
Posts: 150
Joined: Fri May 06, 2011 11:37 am

Re: 10642 - Can You Solve It?

Post by plamplam » Wed Jul 13, 2011 11:42 pm

It's a mess....shitty thing...the graph is actually inverted. I mean the x-axis labeled is the traditional y-axis and the y-axis is the traditional x-axis. Very easy problem but it took me some time to solve this just because of this inversion thing. :x :x
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson

Mukit Chowdhury
Learning poster
Posts: 98
Joined: Fri Aug 17, 2012 9:23 pm
Location: Dhaka
Contact:

Re:

Post by Mukit Chowdhury » Mon Jan 21, 2013 8:07 pm

Arm.Turbo wrote:Input:

Code: Select all

100
41 8467 6334 6500
9169 5724 1478 9358
6962 4464 5705 8145
3281 6827 9961 491
2995 1942 4827 5436
2391 4604 3902 153
292 2382 7421 8716
9718 9895 5447 1726
4771 1538 1869 9912
5667 6299 7035 9894
8703 3811 1322 333
7673 4664 5141 7711
8253 6868 5547 7644
2662 2757 37 2859
8723 9741 7529 778
2316 3035 2190 1842
288 106 9040 8942
9264 2648 7446 3805
5890 6729 4370 5350
5006 1101 4393 3548
9629 2623 4084 9954
8756 1840 4966 7376
3931 6308 6944 2439
4626 1323 5537 1538
6118 2082 2929 6541
4833 1115 4639 9658
2704 9930 3977 2306
1673 2386 5021 8745
6924 9072 6270 5829
6777 5573 5097 6512
3986 3290 9161 8636
2355 4767 3655 5574
4031 2052 7350 1150
6941 1724 3966 3430
1107 191 8007 1337
5457 2287 7753 383
4945 8909 2209 9758
4221 8588 6422 4946
7506 3030 6413 9168
900 2591 8762 1655
7410 6359 7624 537
1548 6483 7595 4041
3602 4350 291 836
9374 1020 4596 4021
7348 3199 9668 4484
8281 4734 53 1999
6418 7938 6900 3788
8127 467 3728 4893
4648 2483 7807 2421
4310 6617 2813 9514
4309 7616 8935 7451
600 5249 6519 1556
2798 303 6224 1008
5844 2609 4989 2702
3195 485 3093 4343
523 1587 9314 9503
7448 5200 3458 6618
580 9796 4798 5281
9589 798 8009 7157
472 3622 8538 2292
6038 4179 8190 9657
7958 6191 9815 2888
9156 1511 6202 2634
4272 55 328 2646
6362 4886 8875 8433
9869 142 3844 1416
1881 1998 322 8651
21 5699 3557 8476
7892 4389 5075 712
2600 2510 1003 6869
7861 4688 3401 9789
5255 6423 5002 585
4182 285 7088 1426
8617 3757 9832 932
4169 2154 5721 7189
9976 1329 2368 8692
1425 555 3434 6549
7441 9512 145 8060
1718 3753 6139 2423
6279 5996 6687 2529
2549 7437 9866 2949
193 3195 3297 416
8286 6105 4488 6282
2455 5734 8114 1701
1316 671 5786 2263
4313 4355 1185 53
912 808 1832 945
4313 7756 8321 9558
3646 7982 481 4144
3196 222 7129 2161
5535 450 1173 466
2044 1659 6292 6439
7253 24 6154 9510
4745 649 3186 8313
4474 8022 2168 4018
8787 9905 7958 7391
202 3625 6477 4414
9314 5824 9334 5874
4372 159 1833 8070
7487 8297 7518 8177
Output:

Code: Select all

Case 1: 46171202
Case 2: 52200996
Case 3: 30634467
Case 4: 3543172
Case 5: 40482095
Case 6: 16243459
Case 7: 126640107
Case 8: 166619411
Case 9: 49494074
Case 10: 71706792
Case 11: 76943396
Case 12: 6483893
Case 13: 27324751
Case 14: 10493259
Case 15: 135962796
Case 16: 6188874
Case 17: 161616090
Case 18: 7657520
Case 19: 32383350
Case 20: 12882320
Case 21: 23472318
Case 22: 20021957
Case 23: 8395631
Case 24: 7333986
Case 25: 11217896
Case 26: 84516733
Case 27: 60072836
Case 28: 86521839
Case 29: 54745710
Case 30: 8878860
Case 31: 131906952
Case 32: 17228132
Case 33: 17628083
Case 34: 10194314
Case 35: 42823689
Case 36: 3114972
Case 37: 24365793
Case 38: 17418048
Case 39: 65881562
Case 40: 48174729
Case 41: 61494310
Case 42: 35457617
Case 43: 30988811
Case 44: 16896940
Case 45: 44524070
Case 46: 82603470
Case 47: 45932048
Case 48: 228017
Case 49: 26885119
Case 50: 16277003
Case 51: 63154542
Case 52: 15504444
Case 53: 21348303
Case 54: 6152100
Case 55: 20877624
Case 56: 174830839
Case 57: 29228340
Case 58: 3033498
Case 59: 61059703
Case 60: 50275466
Case 61: 107070127
Case 62: 19412862
Case 63: 17858866
Case 64: 4943747
Case 65: 86530223
Case 66: 36284661
Case 67: 32735032
Case 68: 56044037
Case 69: 58672860
Case 70: 17927926
Case 71: 8245210
Case 72: 52583856
Case 73: 26271983
Case 74: 18625680
Case 75: 63348731
Case 76: 2747443
Case 77: 47875955
Case 78: 110052762
Case 79: 21693968
Case 80: 32871606
Case 81: 32260746
Case 82: 1157179
Case 83: 45559599
Case 84: 14643724
Case 85: 30426617
Case 86: 36807633
Case 87: 2378113
Case 88: 87005853
Case 89: 56916546
Case 90: 37317557
Case 91: 16573487
Case 92: 74191838
Case 93: 96206178
Case 94: 51567376
Case 95: 58947171
Case 96: 56902032
Case 97: 51993783
Case 98: 1062165
Case 99: 38769871
Case 100: 1400829
Sorry to say...some of your case is not valid..like case 2.case 6 & case 8.... there can be more..but I didn't check... In those cases we can't go from source to destination... as they are directed... if you draw until these points come,you will see your destination point will come first,then the source point... but it'll never given in judge's input... I just ignored such kinds of inputs & got accepted too....
Last edited by Mukit Chowdhury on Thu Nov 28, 2013 9:07 am, edited 1 time in total.

Post Reply

Return to “Volume 106 (10600-10699)”