Блог пользователя trunghieu11

Автор trunghieu11, история, 9 лет назад, По-английски

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
  • Проголосовать: не нравится

Автор trunghieu11, 9 лет назад, По-английски

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
  • Проголосовать: не нравится

Автор trunghieu11, 11 лет назад, По-английски

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
  • Проголосовать: не нравится

Автор trunghieu11, 11 лет назад, По-английски

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
  • Проголосовать: не нравится

Автор trunghieu11, 12 лет назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится