On September 22, 2004, Oceanic Flight 815 crashed on a mysterious island somewhere in the pacific. There actually were survivors in the crash , N survivors . The mysterious island kept on moving in space - time, so no rescue reached them. Initially e…
Taplu and Abhishar loved playing scrabble. One day they thought of inventing a new game using alphabet tiles. Abhishar wrote a string using tiles and gave a set of pairs (i,j) to Taplu. Pair “i, j” (0 based indexing) means that Taplu can swap the i’t…
Stack is a basic data structure. Where 3 operation can be done- Push: You can push object to the stack Pop: You can pop the object to the stack Top: You can check the value of the top object. For further details you can get idea here ( if you really…
C. Glass Carving time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a re…
思路: 利用并查集/DFS都可以处理连通问题. PS:注意Find()查找值和pre[]值的区别. #include<bits/stdc++.h> using namespace std; const int N=1e3+10; int val[N]; int pre[N],n,m; vector<int>xs,ans; int Find(int x) { int r=x; while(pre[r]!=r) r=pre[r]; int i=x,j; while(pre[i]!=r)…
题目描述: Taplu and Abhishar loved playing scrabble. One day they thought of inventing a new game using alphabet tiles. Abhishar wrote a string using tiles and gave a set of pairs (i,j) to Taplu. Pair “i, j” (0 based indexing) means that Taplu can swap t…