661 - Blowing Fuses
Moderator: Board moderators
-
- New poster
- Posts: 20
- Joined: Fri Aug 30, 2013 5:42 am
Re: 661 - Blowing Fuses
What a silly mistake !
Thanks.
Thanks.
Re: 661 - Blowing Fuses
What brianfry713 mentioned is true. I'd like to elucidate on this some more. For the following inputbrianfry713 wrote:Output a blank line after each test case.
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
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.
-
- 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.
-
- 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
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!
-
- 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
Re: 661 - Blowing Fuses
Input:
AC Output:
![:-)](./images/smilies/icon_smile.gif)
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
Code: Select all
Fuse was blown.
![:-)](./images/smilies/icon_smile.gif)
-
- 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!
-
- 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.
Re: 661 - Blowing Fuses
Change the spelling ofterry646623 wrote:Help I got wrong answer
Squence
to
Sequence
on Line #39 and Line #43.
-
- 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;
}
}
-
- 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!
-
- 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;
}
}
Re: 661 - Blowing Fuses
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.ultima_key wrote:still getting WA. What could be the problem?
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;
-
- New poster
- Posts: 10
- Joined: Tue Mar 25, 2014 12:50 pm
Re: 661 - Blowing Fuses
v1n1t wrote: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.ultima_key wrote:still getting WA. What could be the problem?
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;
Re: 661 - Blowing Fuses
If you need help, post the exact code that's giving you a WA.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.