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 ...
随机推荐
- 模拟赛1101d1
完美的序列(sequence)Time Limit:1000ms Memory Limit:64MB题目描述LYK 认为一个完美的序列要满足这样的条件:对于任意两个位置上的数都不相同.然而并不是所有的 ...
- 第三章 C#循环与方法
第一节1-For循环入门 语法: for(条件表达式) { 执行语句 } 练习: 第三章作业1.写一个程序打印100到200的值;2.写一个程序从10打印到1:3.写一个程序打印10到30之间的所有偶 ...
- 自定义UIDatePikerView
1.添加文件GoYearMonthDayPickerView.h .m .xib.NSDate+Helper.h .m.iCarousel.h .m 2.在Lable上显示日期 UILabel *ag ...
- 利用bak文件恢复数据库问题小结
对备份的基础理解: --完整备份:完整备份会备份所有数据的区和少量的日志(日志文件用于恢复数据保持数据一致性).由于差异备份需要依据最后一次完整备份,因此完整备份会清楚一些分配位图数据. --差异备份 ...
- Android -- getQuantityString无效
原文:http://www.xuebuyuan.com/1510993.html 原因:中文没有复数语法.
- HashMap在并发下可能出现的问题分析
我们都知道,HashMap在并发环境下使用可能出现问题,但是具体表现,以及为什么出现并发问题,可能并不是所有人都了解,这篇文章记录一下HashMap在多线程环境下可能出现的问题以及如何避免. 在分析H ...
- HTML5学习之画布和SVG(四)
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- centos(x86 64位系统)使用boost
1. 安装gcc,g++,make等开发环境 yum groupinstall "Development Tools" 2. 安装boost yum install boost b ...
- PMP 第二章 项目生命周期与组织
1 项目组织机构类型有哪些? 区别是什么? 职能型 矩阵型 项目性 2 什么是事业环境因素? 什么是组织过程资产? 如何区分事业环境因素和组织过程资产? 事业环境因素:事业环境因素指围绕项目或能影 ...
- 配置tomcat下war包可以自压缩
<Host name="localhost" appBase="/home/hark/web" unpackWARs="true" a ...