You are given a 4x4 grid. You play a game — there is a sequence of tiles, each of them is either 2x1 or 1x2. Your task is to consequently place all tiles from the given sequence in the grid. When tile is placed, each cell which is located in fully occupied row or column is deleted (cells are deleted at the same time independently). You can place tile in the grid at any position, the only condition is that tiles (and tile parts) should not overlap. Your goal is to proceed all given figures and avoid crossing at any time.

Input

The only line contains a string ss consisting of zeroes and ones (1≤|s|≤10001≤|s|≤1000). Zero describes vertical tile, one describes horizontal tile.

Output

Output |s||s| lines — for each tile you should output two positive integers r,cr,c, not exceeding 44, representing numbers of smallest row and column intersecting with it.

If there exist multiple solutions, print any of them.

Example

input

Copy

010

output

Copy

1 1
1 2
1 4

Note

Following image illustrates the example after placing all three tiles:

Then the first row is deleted:

思路:我们可以建立两个数组,如果是0我们就把它放在第一列的两个位置,满了就消去,如果是1我们就放在最右边两列,满了就消去

代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm> using namespace std;
string str;
int main()
{
int a[2][2]={1,1,3,1};
int b[4][2]={1,3,2,3,3,3,4,3};
cin>>str;
int len=str.length();
int s1=0;
int s2=0;
for(int t=0;t<len;t++)
{
if(str[t]=='0')
{
cout<<a[s1][0]<<" "<<a[s1][1]<<endl;
s1++;
}
if(str[t]=='1')
{
cout<<b[s2][0]<<" "<<b[s2][1]<<endl;
s2++;
}
if(s1==2)
{
s1=0;
}
if(s2==4)
{
s2=0;
}
} return 0;
}

Codeforces-C-Grid game(思维)的更多相关文章

  1. C. Grid game 思维+问题转化

    C. Grid game 思维+问题转化 题意 每当有一行或者一列方格的时候,都可以消气这一行或者这一列,一共有两种形状的方块,一种是横的两个,一种是竖着的两个,按时间顺序放在4*4的格子里面,问怎么 ...

  2. Educational Codeforces Round 60 C 思维 + 二分

    https://codeforces.com/contest/1117/problem/C 题意 在一个二维坐标轴上给你一个起点一个终点(x,y<=1e9),然后给你一串字符串代表每一秒的风向, ...

  3. Educational Codeforces Round 61 F 思维 + 区间dp

    https://codeforces.com/contest/1132/problem/F 思维 + 区间dp 题意 给一个长度为n的字符串(<=500),每次选择消去字符,连续相同的字符可以同 ...

  4. [Codeforces 1178D]Prime Graph (思维+数学)

    Codeforces 1178D (思维+数学) 题面 给出正整数n(不一定是质数),构造一个边数为质数的无向连通图(无自环重边),且图的每个节点的度数为质数 分析 我们先构造一个环,每个点的度数都是 ...

  5. CF--思维练习-- CodeForces - 215C - Crosses(思维题)

    ACM思维题训练集合 There is a board with a grid consisting of n rows and m columns, the rows are numbered fr ...

  6. Sorted Adjacent Differences(CodeForces - 1339B)【思维+贪心】

    B - Sorted Adjacent Differences(CodeForces - 1339B) 题目链接 算法 思维+贪心 时间复杂度O(nlogn) 1.这道题的题意主要就是让你对一个数组进 ...

  7. Codeforces 675C Money Transfers 思维题

    原题:http://codeforces.com/contest/675/problem/C 让我们用数组a保存每个银行的余额,因为所有余额的和加起来一定为0,所以我们能把整个数组a划分为几个区间,每 ...

  8. Mike and distribution CodeForces - 798D (贪心+思维)

    题目链接 TAG: 这是我近期做过最棒的一道贪心思维题,不容易想到,想到就出乎意料. 题意:给定两个含有N个正整数的数组a和b,让你输出一个数字k ,要求k不大于n/2+1,并且输出k个整数,范围为1 ...

  9. Codeforces 1090D - Similar Arrays - [思维题][构造题][2018-2019 Russia Open High School Programming Contest Problem D]

    题目链接:https://codeforces.com/contest/1090/problem/D Vasya had an array of n integers, each element of ...

  10. Maximal GCD CodeForces - 803C (数论+思维优化)

    C. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input ...

随机推荐

  1. strophe与openfire模拟的XMPP简单hello程序

    /* * 参考<XMPP高级编程+使用JavaScript和jQuery>第三章例子. * 我修改了作者的XMPP服务器到本地的openfire.JavaScript跨域请求,使用Ngin ...

  2. PCL—关键点检测(NARF)低层次点云处理

    博客转载自:http://www.cnblogs.com/ironstark/p/5051533.html 关键点检测本质上来说,并不是一个独立的部分,它往往和特征描述联系在一起,再将特征描述和识别. ...

  3. UltraISO制作系统ISO镜像

    一.简介 UltraISO是一款功能强大而又方便实用的光盘映像文件制作/编辑/转换工具,它可以直接编辑ISO文件和从ISO中提取文件和目录,也可以从CD-ROM制作光盘映像或者将硬盘上的文件制作成IS ...

  4. conda 添加bioconda源,创建/删除/重命名环境

    1.conda安装 在https://repo.continuum.io/miniconda/选择conda版本 wget "https://repo.continuum.io/archiv ...

  5. sed编辑器使用(转)

    1.Sed简介 sed 是一种在线编辑器,它一次处理一行内容.处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后, ...

  6. Newtonsoft Json操作类库的使用

    1.解析简单Json字符串 if (l_sSenJson != "") { JObject obj2 = (JObject)JsonConvert.DeserializeObjec ...

  7. asp.net mvc3.0安装失败之终极解决方案

    安装失败截图 原因分析 因为vs10先安装了sp1补丁,然后安装的mvc3.0,某些文件被sp1补丁更改,导致“VS10-KB2483190-x86.exe”安装不了,造成安装失败. 解决方案 方法1 ...

  8. Date的转换输出

    public static void main(String[] args) { // TODO Auto-generated method stub //20131111怎么格式化成2013年11月 ...

  9. 微信创建带参数二维码,并加上logo

    现在需要创建一个场景二维码,除了基础的微信接口创建外,需要加上小logo,思路如下: 1. 首先根据微信的开发文档创建二维码,获取二维码的url,没啥可说的,按照文档来就好了 获取到的二维码就是这么素 ...

  10. K-Dominant Character (模拟)

    You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff ...