## 661 - Blowing Fuses

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

Moderator: Board moderators

cyberdragon
New poster
Posts: 20
Joined: Fri Aug 30, 2013 5:42 am

### Re: 661 - Blowing Fuses

What a silly mistake !
Thanks.

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

### Re: 661 - Blowing Fuses

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.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

abdulrehman_libra
New poster
Posts: 1
Joined: Tue Jan 07, 2014 12:17 am

### Re: 661 - Blowing Fuses

got AC !! Thank u All for help ...
Last edited by abdulrehman_libra on Sat Jan 25, 2014 10:40 pm, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 661 - Blowing Fuses

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
Check input and AC output for thousands of problems on uDebug!

Rocker3011
New poster
Posts: 6
Joined: Mon Feb 17, 2014 12:21 am

### Re: 661 - Blowing Fuses

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

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

### Re: 661 - Blowing Fuses

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.``
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 661 - Blowing Fuses

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.
Check input and AC output for thousands of problems on uDebug!

terry646623
New poster
Posts: 8
Joined: Fri Jan 17, 2014 3:35 pm

### Re: 661 - Blowing Fuses

Help I got wrong answer

Code: Select all

``````got AC. Careless spelling mistake...
``````
Last edited by terry646623 on Tue Mar 04, 2014 6:20 am, edited 1 time in total.

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

### Re: 661 - Blowing Fuses

terry646623 wrote:Help I got wrong answer
Change the spelling of

Squence

to

Sequence

on Line #39 and Line #43.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

ultima_key
New poster
Posts: 10
Joined: Tue Mar 25, 2014 12:50 pm

### Re: 661 - Blowing Fuses

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?

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 661 - Blowing Fuses

You're printing two blank lines at the end of the output.
Check input and AC output for thousands of problems on uDebug!

ultima_key
New poster
Posts: 10
Joined: Tue Mar 25, 2014 12:50 pm

### Re: 661 - Blowing Fuses

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?

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

### Re: 661 - Blowing Fuses

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;``
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

ultima_key
New poster
Posts: 10
Joined: Tue Mar 25, 2014 12:50 pm

### Re: 661 - Blowing Fuses

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.

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

### Re: 661 - Blowing Fuses

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.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.