Page 4 of 5

Re: 661 - Blowing Fuses

Posted: Wed Sep 25, 2013 1:48 am
by cyberdragon
What a silly mistake !
Thanks.

Re: 661 - Blowing Fuses

Posted: Tue Dec 17, 2013 7:00 am
by uDebug
brianfry713 wrote:Output a blank line after each test case.
What brianfry713 mentioned is true. I'd like to elucidate on this some more. For the following input

Code: Select all

5 3 9
7
6
6
7
2
3
2
2
3 9 10
5
3
5
3
2
3
3
2
1
1
3
2
1 1 20
20
1
0 0 0
The AC output is

Code: Select all

Sequence 1
Fuse was blown.

Sequence 2
Fuse was not blown.
Maximal power consumption was 10 amperes.

Sequence 3
Fuse was not blown.
Maximal power consumption was 20 amperes.

As expected, there's a blank between sequences. However, note that there's also a blank line after the last output. If you don't print this blank line, your code will get a WA.

Re: 661 - Blowing Fuses

Posted: Mon Jan 20, 2014 11:01 am
by abdulrehman_libra
got AC !! Thank u All for help ...

Re: 661 - Blowing Fuses

Posted: Mon Jan 20, 2014 9:33 pm
by brianfry713
The input will be terminated by a test case starting with n = m = c = 0
Not
The input will be terminated by a test case starting with n = m = c

Re: 661 - Blowing Fuses

Posted: Mon Feb 17, 2014 12:26 am
by Rocker3011
Its stupid and ridicoulous how they make you print a blank line after last case.... in many problems with this blank line bullcrap, they give you W.A because you do print that last blank line, UVA judge should be modified to give presentation error on this kind of conditions, its annoying as hell

Re: 661 - Blowing Fuses

Posted: Mon Feb 17, 2014 3:02 pm
by uDebug
Input:

Code: Select all

Its stupid and ridicoulous how they make you print a blank line after last case.... in many problems with this blank line bullcrap, they give you W.A because you do print that last blank line, UVA judge should be modified to give presentation error on this kind of conditions, its annoying as hell
AC Output:

Code: Select all

Fuse was blown.
:-)

Re: 661 - Blowing Fuses

Posted: Tue Feb 18, 2014 8:46 pm
by brianfry713
Missing or extra newlines will usually result in WA, don't ever count on getting PE. Read the problem statement carefully. Output a blank line after each test case includes the last test case.

Re: 661 - Blowing Fuses

Posted: Sun Mar 02, 2014 4:33 pm
by terry646623
Help I got wrong answer

Code: Select all

got AC. Careless spelling mistake...

Re: 661 - Blowing Fuses

Posted: Mon Mar 03, 2014 7:18 am
by uDebug
terry646623 wrote:Help I got wrong answer
Change the spelling of

Squence

to

Sequence

on Line #39 and Line #43.

Re: 661 - Blowing Fuses

Posted: Tue Mar 25, 2014 12:53 pm
by ultima_key

Code: Select all

#include <iostream>
#include <cstring>
using namespace std;

int main(){
	long long n,m,c;
	int x=1;
	while(cin >> n >> m >> c){
		if(n==0 && m==0 && c==0){ cout << endl; break; }
		long long amp[n], op[m];
		bool swtch[n];
		memset(swtch, false, sizeof(swtch));
		for(int i = 1; i <= n; i++) cin >> amp[i];
		long long cons=0, max=0;
		for(int i = 0; i < m; i++) cin >> op[i];
		for(int i = 0; i < m; i++){
			if(swtch[op[i]] == false){
				swtch[op[i]] = true;
				cons += amp[op[i]];
				if(cons > max) max = cons;
			}
			else{
				swtch[op[i]] = false;
				cons -= amp[op[i]];
			}
		}
		if(cons <= c){
			cout << "Sequence " << x++ << endl;
			cout << "Fuse was not blown." << endl;
			cout << "Maximal power consumption was " << max << " amperes." << endl;
		}
		else{
			cout << "Sequence " << x++ << endl;
			cout << "Fuse was blown." << endl;
		}
		cout << endl;
	}
}
It gives me a wrong answer? Why is that?

Re: 661 - Blowing Fuses

Posted: Wed Mar 26, 2014 12:41 am
by brianfry713
You're printing two blank lines at the end of the output.

Re: 661 - Blowing Fuses

Posted: Wed Apr 02, 2014 3:04 pm
by ultima_key
brianfry713 wrote:You're printing two blank lines at the end of the output.

Code: Select all

#include <iostream>
#include <cstring>
using namespace std;

int main(){
	long long n,m,c;
	int x=1;
	while(cin >> n >> m >> c){
		if(n==0 && m==0 && c==0){ break; }
		long long amp[n], op[m];
		bool swtch[n];
		memset(swtch, false, sizeof(swtch));
		for(int i = 1; i <= n; i++) cin >> amp[i];
		long long cons=0, max=0;
		for(int i = 0; i < m; i++) cin >> op[i];
		for(int i = 0; i < m; i++){
			if(swtch[op[i]] == false){
				swtch[op[i]] = true;
				cons += amp[op[i]];
				if(cons > max) max = cons;
			}
			else{
				swtch[op[i]] = false;
				cons -= amp[op[i]];
			}
		}
		if(cons <= c){
			cout << "Sequence " << x++ << endl;
			cout << "Fuse was not blown." << endl;
			cout << "Maximal power consumption was " << max << " amperes." << endl;
		}
		else{
			cout << "Sequence " << x++ << endl;
			cout << "Fuse was blown." << endl;
		}
		cout << "a" << endl;
	}
}
still getting WA. What could be the problem?

Re: 661 - Blowing Fuses

Posted: Wed Apr 02, 2014 3:14 pm
by uDebug
ultima_key wrote:still getting WA. What could be the problem?
Try running your code at least once and consider looking at it objectively. This thread has some test cases. Check your code output against what's available on the forums.

So, you're no longer printing two lines at the end of the output but what do you think this line in your code is doing?

Code: Select all

 cout << "a" << endl;

Re: 661 - Blowing Fuses

Posted: Thu Apr 03, 2014 4:46 pm
by ultima_key
v1n1t wrote:
ultima_key wrote:still getting WA. What could be the problem?
Try running your code at least once and consider looking at it objectively. This thread has some test cases. Check your code output against what's available on the forums.

So, you're no longer printing two lines at the end of the output but what do you think this line in your code is doing?

Code: Select all

 cout << "a" << endl;

Code: Select all

cout << "a" << endl;
It was for me to debug my code. I also tried all the test cases found in this forum. It outputs fine but still WA.

Re: 661 - Blowing Fuses

Posted: Thu Apr 03, 2014 5:11 pm
by uDebug
ultima_key wrote:It was for me to debug my code. I also tried all the test cases found in this forum. It outputs fine but still WA.
If you need help, post the exact code that's giving you a WA.