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 ... 
随机推荐
- ASP.NET Global 全局事件处理
			添加Global文件,名字不要改 Global类说明: using System; using System.Collections.Generic; using System.IO; using S ... 
- 第四章 面向对象与IO操作
			一.类(类中可以写字段.属性.方法.构造函数)1.定义一个类用关键字class,后面加类名,类名第一个字母用大写,可用private或public修饰符定义访问级别,类可定义在同一命名空间中,也可定义 ... 
- 添加本地jar到Maven库
			转自:http://dk05408.iteye.com/blog/2170986 上传: mvn install:install-file -Dfile=D:/workspace/p2p_server ... 
- 使用Gson送解析Json格式
			Java bean: package com.jingle.a; public class Person { public String name; public int age; public Pe ... 
- tar 只解压tar包中某个文件
			sh-4.1# ls test.tar sh-4.1# tar -tf test.tar ./ecs20161207.png ./ecs.png ./ecs.xml ./rds.png ./Scree ... 
- linux中解决SSH连接慢问题 关键点GSSAPIAuthentication
			[root@ok 6FE5-D831]# ssh -v xxx.xxx.xxx.64 OpenSSH_5.3p1, OpenSSL Feb debug1: Reading configuration ... 
- htop 源码安装
			htop-1.0.2.tar.gz http://pan.baidu.com/s/1c1RbdIg tar -xvf htop-1.0.2.tar.gz cd htop-1.0.2 ./config ... 
- 无废话Android之smartimageview使用、android多线程下载、显式意图激活另外一个activity,检查网络是否可用定位到网络的位置、隐式意图激活另外一个activity、隐式意图的配置,自定义隐式意图、在不同activity之间数据传递(5)
			1.smartimageview使用 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android&q ... 
- 【PHP&&FileIO】
			在程序员的眼中,文件不应当仅仅是一部电影.一首歌曲.一个pdf文件,它应该被视为一个文件夹,而我们所熟知的文件,应当是它的特例. 在web开发中,文件的上传和下载是文件变成的一个实际应用. 延续cru ... 
- 7-15ALL、 ANY、SOME子查询
			ALL:所有 ANY:部分 SOME:与ANY相同,使用ANY的地方都可以用SOME替换. >ALL:父查询中列的值必须大于子查询返回的值列表的每一个值. >ANY:父查询中的返回值必须大 ... 
