题目链接 求有向图强连通分量的2n个边的边集 首先从1开始DFS可以走到的所有点,并记录走过的边 这样就满足了从1可达所有其他点 然后从1开始DFS走反向边,这样保证其他点可达1点. 两遍dfs #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e5+5; struct node { int to; int ind; }; int u[maxn]; int v[maxn]; int ans[maxn]; vector<node> G[maxn]; vector<node> G1[maxn]; int T; int n,m; int vis[maxn]; void dfs(int cur) { vis[cur]=1; for(int i=0;i<G[cur].size();i++ 继续阅读 >>


楚东方 17/12/12 22:07:10
题目链接 大神题解: //解题思路:重点就是抓住异或的性质,两个相同的数异或等于0, //任何数异或0结果都不变。意思就是例如 3^4^5^3^4^5^6=6 。 //然后这道题就很简单了。假设我们要使最后的结果为X,大小为4, //那么我们可以 a^b^c^(a^b^c)^x=x,其中四个数分别为, //a,b,c,(a^b^c)。但是a^b^c可能等于a,b,c中的一个数, //所以我们要用一些足够特殊的数完成这个操作。题目告诉了每个数的最大值。具体看代码实现。 #include<bits/stdc++.h> using namespace std; //解题思路:重点就是抓住异或的性质,两个相同的数异或等于0, //任何数异或0结果都不变。意思就是例如 3^4^5^3^4^5^6=6 。 //然后这道题就很简单了。假设我们要使最后的结果为X,大小为4, //那么我们可以 a^b^c^(a^b^c)^x=x,其中四个数分别为, //a,b,c,(a^b^c)。但是a^b^c可能等于a,b,c中的一个数, / 继续阅读 >>


楚东方 17/09/20 21:55:24
Valera had an undirected connected graph without self-loops and multiple edges consisting of nvertices. The graph had an interesting property: there were at most k edges adjacent to each of its vertices. For convenience, we will assume that the graph vertices were indexed by integers from 1 to n. One day Valera counted the shortest distances from one of the graph vertices to all other ones and wrote them out in array d. Thus, element d[i] of 继续阅读 >>


楚东方 17/09/15 00:06:19
LINUX_C 线程总结(二) 话不多说,我们先来看一段代码 /************************************************************************* > File Name: condition.c > Author:九五二七 > Mail: > Created Time: 2017年08月02日 星期三 07时59分08秒 ************************************************************************/ #include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<pthread.h> pthread_mutex_t mutex; //静态 pthread_cond_t cond 继续阅读 >>


刘嘉辉 17/08/05 11:13:55
LINUX_C 线程总结(一) 首先来说说我所理解的线程: 但是谈线程又不得不得提一下进程,程序,这三者的联系 或许弄清楚这三种的联系之后,我们或许能够更好的来对这些系统级的实体有一个更加深刻的认知。 程序,进程,线程这三者之间的关系? 简单来说,一程序可以调用多个进程,比如一个视频播放器程序,里面就存在两个进程:一个是播放视频的进程,一个是下载上传视频的进程。 一个进程又同时调用多个线程, 这个线程是隐藏的,用进程管理器看不到,可用其它的进程管理软件来查看。 三者的逻辑关系是程序调用进程,进程调用线程,一般来说程序下面都是多进程,不同的进程分工不同;进程下面也基本上是多线程的。 可以这样下定义:进程是系统进行资源分配和调用的独立单位,每一个进程,都由它自己的内存空间和系统资源 线程是进程的执行单元,执行路径,线程也是程序使用CPU的最基本单位 学习过程中都能踩了那些坑 i.首先, 就是线程创建函数 c include 这函数比较坑 继续阅读 >>


刘嘉辉 17/08/05 10:54:06
C. Jon Snow and his Favourite Number time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve 继续阅读 >>


楚东方 17/02/21 10:09:45
C. MUH and House of Cards time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: The house consists of some non-zero number of floors. Each floor consist 继续阅读 >>


楚东方 17/02/06 10:08:18
New Year is coming, and Jaehyun decided to read many books during 2015, unlike this year. He has n books numbered by integers from 1 to n. The weight of the i-th (1 ≤ i ≤ n) book is wi. As Jaehyun's house is not large enough to have a bookshelf, he keeps the n books by stacking them vertically. When he wants to read a certain book x, he follows the steps described below. He lifts all the books above book x.He pushes book&n 继续阅读 >>


楚东方 17/01/15 16:15:40
C. Felicity is Coming! time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There i 继续阅读 >>


楚东方 17/01/13 14:20:52
You have r red, g green and b blue balloons. To decorate a single table for the banquet you need exactly three balloons. Three balloons attached to some table shouldn't have the same color. What maximum number t of tables can be decorated if we know number of balloons of each color? Your task is to write a program that for given values r, g and b will find the maximum number t of tables, that can be de 继续阅读 >>


楚东方 16/12/31 16:30:29