ural 1249. Ancient Necropolis
1249. Ancient Necropolis
Memory limit: 4 MB
Input
Output
Samples
input | output |
---|---|
2 2 |
No |
3 3 |
Yes |
Problem Source: Open collegiate programming contest for student teams, Ural State University, March 15, 2003
/**
Create By yzx - stupidboy
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef double DB;
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define ft first
#define sd second
#define mk make_pair inline int Getint()
{
int ret = ;
char ch = ' ';
bool flag = ;
while(!(ch >= '' && ch <= ''))
{
if(ch == '-') flag ^= ;
ch = getchar();
}
while(ch >= '' && ch <= '')
{
ret = ret * + ch - '';
ch = getchar();
}
return flag ? -ret : ret;
} const int N = ;
int n, m, graph[N], data[N]; inline void Input()
{
// scanf("%d%d", &n, &m);
n = Getint();
m = Getint();
} inline void Move(int &l, int &r, int *arr)
{
for(l = r + ; l <= m && !arr[l]; l++);
for(r = l; r < m && arr[r + ]; r++);
} inline void Solve()
{
bool ans = ;
for(int i = ; i <= n && ans; i++)
{
for(int j = ; j <= m; j++)
data[j] = Getint(); int l1, r1 = , l2, r2 = ;
for(l1 = ; l1 <= m && !graph[l1]; l1++);
for(r1 = l1; r1 < m && graph[r1 + ]; r1++);
for(l2 = ; l2 <= m && !data[l2]; l2++);
for(r2 = l2; r2 < m && data[r2 + ]; r2++);
while(l1 <= m && l2 <= m)
{
if(r1 < l2) Move(l1, r1, graph);
else if(r2 < l1) Move(l2, r2, data);
else if(l1 == l2 && r1 == r2)
{
Move(l1, r1, graph);
Move(l2, r2, data);
}
else
{
ans = ;
break;
}
} for(int j = ; j <= m; j++) graph[j] = data[j];
} puts(ans ? "Yes" : "No");
} int main()
{
freopen("a.in", "r", stdin);
Input();
Solve();
return ;
}
ural 1249. Ancient Necropolis的更多相关文章
- URAL ——1249——————【想法题】
Ancient Necropolis Time Limit:5000MS Memory Limit:4096KB 64bit IO Format:%I64d & %I64u ...
- ural 1255. Graveyard of the Cosa Nostra
1255. Graveyard of the Cosa Nostra Time limit: 1.0 secondMemory limit: 64 MB There is a custom among ...
- ural 1250. Sea Burial
1250. Sea Burial Time limit: 1.0 secondMemory limit: 64 MB There is Archipelago in the middle of a s ...
- ural 1243. Divorce of the Seven Dwarfs
1243. Divorce of the Seven Dwarfs Time limit: 1.0 secondMemory limit: 64 MB After the Snow White wit ...
- URAL 1277 Cops and Thieves
Cops and Thieves Time Limit: 1000ms Memory Limit: 16384KB This problem will be judged on Ural. Origi ...
- URAL - 1243 - Divorce of the Seven Dwarfs (大数取模)
1243. Divorce of the Seven Dwarfs Time limit: 1.0 second Memory limit: 64 MB After the Snow White wi ...
- Ancient Printer[HDU3460]
Ancient Printer Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Tot ...
- 【英语学习】2016.09.11 Culture Insider: Teacher's Day in ancient China
Culture Insider: Teacher's Day in ancient China 2016-09-10 CHINADAILY Today is the 32nd Chinese Te ...
- Good Bye 2015 D. New Year and Ancient Prophecy
D. New Year and Ancient Prophecy time limit per test 2.5 seconds memory limit per test 512 megabytes ...
随机推荐
- C#冒泡排序
C#最简单的冒泡排序,需要的朋友可作参考: 思路: 使用两个for循环,就可以遍历数组,这样就可以确保每个数组元素都被使用 对比前后两个数,将小的数字和大的交换位置,引入一个临时变量temp来进行交换 ...
- NYOJ题目1051simone牌文本编辑器
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAsgAAAKFCAIAAABeD4iTAAAgAElEQVR4nO3dO3LjOtOA4X8TzrUQx1
- iOS,Objective-C,相册功能的实现。
#import "ViewController.h" #define kuan [UIScreen mainScreen].bounds.size.width #define ga ...
- JDBC 精度
http://www.cnblogs.com/tobecrazy/p/3390021.html http://www.cnblogs.com/kerrycode/p/4034231.html http ...
- mysql基础一
一.概述 1.什么是数据库 ? 答:数据的仓库,如:在ATM的示例中我们创建了一个 db 目录,称其为数据库 2.什么是 MySQL.Oracle.SQLite.Access.MS SQL Serve ...
- JavaScript中判断对象类型方法大全2
在JavaScript中,有5种基本数据类型和1种复杂数据类型,基本数据类型有:Undefined, Null, Boolean, Number和String:复杂数据类型是Object,Object ...
- C与C++之间相互调用
1.导出C函数以用于C或C++的项目 如果使用C语言编写的DLL,希望从中导出函数给C或C++的模块访问,则应使用 __cplusplus 预处理器宏确定正在编译的语言.如果是从C++语言模块使用,则 ...
- iOS static
获得20条news 先实现,再提取到business 层. The static Keyword You can have a local variable retain its value thro ...
- 卸载已经安装的rpm包
两个关键点: 1.如果提示有xxx.rpm包已经被installed了,那么先用rpm -e --nodeps xxx来卸载 2.如果存在多个版本的话,用rpm -e --allmatches来卸载 ...
- apk签名(不打包)
apk提交给应用市场加固后,需要重新签名 签名工具:360签名 下载地址:http://yunpan.cn/cm8GqVWL7Y8Eh 签名步骤:http://jiagu.360.cn/qcms/he ...