Codeforces 938.C Constructing Tests】的更多相关文章

C. Constructing Tests time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Let's denote a m-free matrix as a binary (that is, consisting of only 1's and 0's) matrix such that every square submat…
传送门:http://codeforces.com/contest/938/problem/C 给定两个正整数n,m(m≤n),对于一个n阶0-1方阵,其任意m阶子方阵中至少有一个元素“0”,则可以求解这个方阵中的“1”的最大数目.现求解这个问题的逆向问题:已知这个最大数目为X,求相应的n和m. 由原问题可以得到方程:$n^2-\left\lfloor\frac{n}{m}\right\rfloor^2=X\cdots(1)$,于是,对于给定的X,求解不定方程(1). 令$k=\left\lfl…
大意: 定义m-free矩阵: 所有$m*m$的子矩阵至少有一个$0$的$01$矩阵. 定义一个函数$f(n,m)=n*n$的m-free矩阵最大$1$的个数. 给出$t$个询问, 每个询问给出$x$, 求输出$f(n,m)=x$的任意一组$(n,m)$. 显然可以得到$f(n,m)=n^2-\lfloor\frac{n}{m}\rfloor ^2$ #include <iostream> #include <sstream> #include <algorithm>…
题目链接:Buy a Ticket 题意: 给出n个点m条边,每个点每条边都有各自的权值,对于每个点i,求一个任意j,使得2×d[i][j] + a[j]最小. 题解: 这题其实就是要我们求任意两点的最短路,但是从点的个数上就知道这题不可以用floyd算法,其实多元最短路可以用dijkstra算.@.@!把所有的点的权值和点放到结构体里面,放入优先队列,其实这样就能保证每次拓展到的点就是这个点的最短路(因为是优先队列,保证拓展到的点这时候的值是最小的),其实就是这个点想通就很简单. #inclu…
D. Buy a Ticket time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Musicians of a popular band "Flayer" have announced that they are going to "make their exit" with a world tou…
B. Run For Your Prize time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You and your friend are participating in a TV show "Run For Your Prize". At the start of the show n prizes are loc…
A. Word Correction time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really…
You are given three integers aa, bb and xx. Your task is to construct a binary string ssof length n=a+bn=a+b such that there are exactly aa zeroes, exactly bb ones and exactly xx indices ii (where 1≤i<n1≤i<n) such that si≠si+1si≠si+1. It is guarante…
A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\n") #define pb push_back #define inf 1e9 //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<int,vect…
C. Constructing Tests time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Let's denote a m-free matrix as a binary (that is, consisting of only 1's and 0's) matrix such that every square submat…