这两道题都需要用到拓扑排序,所以先介绍一下什么叫做拓扑排序. 这里说一下我是怎么理解的,拓扑排序实在DAG中进行的,根据图中的有向边的方向决定大小关系,具体可以下面的题目中理解其含义 Educational Codeforces Round 25  E. Minimal Labels 题目链接:http://codeforces.com/contest/825/problem/E 题意:给你一个有向无环图(DAG),有n个顶点,m条边,顶点的序号分别是1-n,现在给你1-n的数对n个顶点进行赋值…
题目网址:http://codeforces.com/contest/825/problem/B 题目:   Alice and Bob play 5-in-a-row game. They have a playing field of size 10 × 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current matc…
A:链接:http://codeforces.com/contest/825/problem/A 解题思路: 一开始以为是个进制转换后面发现是我想多了,就是统计有多少个1然后碰到0输出就行,没看清题意.. 实现代码: #include<bits/stdc++.h> using namespace std; int main() { ; string s; cin>>m; cin>>s; ;i<m;i++){ ') ans++; ){ cout<<ans…
题目链接:http://codeforces.com/contest/825/problem/C C. Multi-judge Solving time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Makes solves problems on Decoforces and lots of other different onlin…
题目链接:http://codeforces.com/contest/825/problem/B B. Five-In-a-Row time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alice and Bob play 5-in-a-row game. They have a playing field of size 10 × …
A 题意:给你一个01的字符串,0是个分界点,0把这个字符串分成(0的个数+1)个部分,分别求出这几部分1的个数.例如110011101 输出2031,100输出100,1001输出101 代码: #include<stdio.h>using namespace std;int n;char a[100];int b[100];int main(){ while(~scanf("%d",&n)) { scanf("%s",a); int flag…
E. Minimal Labels time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a directed acyclic graph with n vertices and m edges. There are no self-loops or multiple edges between any p…
题目大意:给你字符串s,和t,字符串s中的'?'可以用字符串t中的字符代替,要求使得最后得到的字符串s(可以将s中的字符位置两两交换,任意位置任意次数)中含有的子串t最多. 解题思路: 因为知道s中的字符位置可以交换无数次,所以只要s中含有可以组成t的字符就一定可以出现子串t.所以就是要令t中的字符数量尽量平均地分布在s中. 代码: #include<iostream> #include<string> using namespace std; ]; int main(){ str…
题目链接:http://codeforces.com/contest/620/problem/E E. New Year Tree time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output The New Year holidays are over, but Resha doesn't want to throw away the N…
Educational Codeforces Round 6 C. Pearls in a Row 题意:一个3e5范围的序列:要你分成最多数量的子序列,其中子序列必须是只有两个数相同, 其余的数只能出现一次. 策略: 延伸:这里指的延伸如当发现1-1如果以最后出现重叠的数为右边界则就表示左延伸,若以1.0.1..0第二个0前一个位置作为右边界就为右延伸: 开始时想是右延伸,考虑到可能只出现一组两个数相同,认为向左延伸会出错,但是直接WA了之后,发现这并不是题目的坑点(其实只需将最后一组改成左右…