Re: 661 - Blowing Fuses
Posted: Wed Sep 25, 2013 1:48 am
What a silly mistake !
Thanks.
Thanks.
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.
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.
Code: Select all
got AC. Careless spelling mistake...
Change the spelling ofterry646623 wrote:Help I got wrong answer
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;
}
}
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;
}
}
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?
Code: Select all
cout << "a" << endl;
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;
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.