### trunghieu11's blog

By trunghieu11, history, 6 years ago,

As I know one of ways for storing a weighted graph is using Adjacency List but cons of this solution is when we want to get weight of a pair vertex this will cost O(n) by looping the adjacency vertex.

So I have a solution to improve that by using Map<NodeID, Map<NodeID, Weight>> then when we want to get weight of a pair vertex, for example (1, 2) we just call Node[1].get(Node[2]), this only cost O(1).

Is this correct? I'm using Java so can it have a risk?

• -3

By trunghieu11, 7 years ago,

Is there any ways we can update Binary Index Tree when it's a min/max tree?

For example, I have an array:

10 4 5 6 8

tree.getMin(3) = 4; //query at index 3 the result is 4

tree.update(2, 1); //update value at index 2 from 5 to 1

tree.getMin(3) = 1; //requery at index 3 we have the new result is 1

Thanks!!

• -8

By trunghieu11, 8 years ago,

In problem http://codeforces.com/contest/296/problem/C I try to create a test for hacking, but I get error "Invalid input". I don't know why my code get this error. Please help me, here's my code:

int main() {
cout << "100000 100000 100000\n";
for (int i = 0; i < 100000; i++) {
if (i)
cout << " ";
cout << "100000";
}
cout << "\n";
for (int i = 0; i < 100000; i++) {
if (i)
cout << "\n";
cout << "1 100000 100000";
}
cout << "\n";
for (int i = 0; i < 100000; i++) {
if (i)
cout << "\n";
cout << "1 100000";
}
cout << "\n";
}


• +5

By trunghieu11, 8 years ago,

In problem http://codeforces.com/contest/296/problem/C I try to create a test for hacking, but I get error "Invalid input". I don't know why my code get this error. Please help me, here's my code:

int main() {
cout << "100000 100000 100000\n";
for (int i = 0; i < 100000; i++) {
if (i)
cout << " ";
cout << "100000";
}
cout << "\n";
for (int i = 0; i < 100000; i++) {
if (i)
cout << "\n";
cout << "1 100000 100000";
}
cout << "\n";
for (int i = 0; i < 100000; i++) {
if (i)
cout << "\n";
cout << "1 100000";
}
cout << "\n";
}


• -3

By trunghieu11, 9 years ago,

Somebody can tell me how to see friend's rating? Thanks so much :D