General question... How would you solve this without using any knowledge outside of what is given in the problem statement. I mean without using all the advanced electricity laws. I've thought about it for quite a while and can't quite figure out how to do it. Please help me.
KL
345 - It's Ir-Resist-Able!
Moderator: Board moderators
-
- Experienced poster
- Posts: 139
- Joined: Wed May 18, 2011 3:04 pm
Re: 345 - It's Ir-Resist-Able!
Test data generator.
Code: Select all
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
srand(time(NULL));
for (int i = 1; i <= 100; i++)
{
int N = rand() % 30 + 2;
vector<string> items;
int S = 1, E = 2;
for (int j = 1; j <= N; j++)
{
if (j == 1 || rand() % 2 == 1)
{
int T = max(S, E);
S = rand() % T + 1;
E = rand() % T + 1;
while (E == S)
E = rand() % T + 1;
}
else
{
if (rand() % 2 == 1)
{
E = max(S, E) + 1;
}
else
{
S = max(S, E);
E = S + 1;
}
}
items.push_back(to_string(S) + ' ' + to_string(E) + ' ' + to_string((rand() % 10000 + 1)));
}
int T = max(S, E);
S = rand() % T + 1;
E = rand() % T + 1;
while (E == S)
E = rand() % T + 1;
items.insert(items.begin(), to_string(N) + ' ' + to_string(S) + ' ' + to_string(E));
for (auto item : items)
cout << item << '\n';
}
cout << "0 0 0\n";
return 0;
}
metaphysis: http://uhunt.onlinejudge.org/id/95895
My solutions for UVa problems: https://github.com/metaphysis/Code.
My solutions for UVa problems: https://github.com/metaphysis/Code.