### 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
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.20323947072029114, "perplexity": 3943.2727536565612}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2021-31/segments/1627046154053.17/warc/CC-MAIN-20210731043043-20210731073043-00491.warc.gz"}