大意: 给定长$n$的字符串$s$, 要求构造一棵树, 满足若第$i$个字符为$1$, 那么可以删一条边, 得到一个大小为$i$的连通块. 若为$0$则表示不存在一条边删去后得到大小为$i$的连通块.

先特判掉显然不成立的情况, 然后构造一个毛毛虫即可

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head const int N = 1e6+10;
char s[N];
int main() {
scanf("%s",s+1);
int n = strlen(s+1);
if (s[1]=='0'||s[n]=='1') return puts("-1"),0;
REP(i,1,n) if (s[i]=='1'&&s[n-i]=='0') return puts("-1"),0;
int rt = 1;
REP(i,2,n) {
printf("%d %d\n",rt,i);
if (s[i-1]=='1') rt = i;
}
}

Tr/ee AtCoder - 4433 (构造)的更多相关文章

  1. AtCoder Regular Contest 103 E Tr/ee

    Tr/ee 思路:按照下图所示连接 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #inclu ...

  2. Robot Arms AtCoder - 4432 (构造)

    大意: 给定平面上$n$个点$(x_i,y_i)$. 要求构造一个序列$d$, $d_i$表示每步走的距离, 再构造$n$个命令串, 要求从原点出发按照第$i$个命令走, 走完恰好到达$(x_i,y_ ...

  3. AtCoder从小白到大神的进阶攻略

    前言 现在全球最大的编程比赛记分网站非CodeForces和AtCoder莫属了,@ezoixx130大佬已经在去年介绍过CodeForces了(传送门),那么现在我们主要谈一下AtCoder. 简介 ...

  4. 【AtCoder】ARC103

    C - //// 为了防止一些多余的判断,我选择直接记录每个数的个数,然后枚举第一个数,找第一个数之外第二个数改变最少的情况下应该选什么 代码 #include <bits/stdc++.h&g ...

  5. AtCoder | ARC103 | 瞎讲报告

    目录 ARC 103 A.//// B.Robot Arms C.Tr/ee D.Distance Sums ARC 103 窝是传送门QwQ A.//// 题意 : 给你\(n\)(\(n\)为偶数 ...

  6. AtCoder Regular Contest 103

    传送门 C - /\/\/\/ 题意: 给出一个序列\(\{a_i\}\),先要求其满足以下条件: \(a_i=a_{i+2}\) 共有两个不同的数 你现在可以修改任意个数,现问最少修改个数为多少. ...

  7. 关于表格动态添加行并处理相关表单元素的一些修改----优化for重用(2)

    功能介绍: 1.处理了动态行与表单的设值问题 2.添加了行的向上或向下排序 3.添加了可以在当前行的下边或上边增加新行的功能 4.添加了可以单选或勾选多项删除不需要的行的功能 5.添加了新增的行的高亮 ...

  8. Linux思维导图之inode、mv、cp和硬软链接

    标准I / O和管道:     ps aux进程管理命令(和win任务管理器一样);     当前命令行输出窗口,键盘的输入即是标准输入.标准输出就是执行了的命令,无法执行的命令或错误信息是标准错误, ...

  9. java容器二:List接口实现类源码分析

    一.ArrayList 1.存储结构 动态数组elementData transient Object[] elementData; 除此之外还有一些数据 //默认初始容量 private stati ...

随机推荐

  1. DDL/DML/DCL区别

    DDL DDL的概述 DDL(Data Definition Language 数据定义语言)用于操作对象和对象的属性,这种对象包括数据库本身,以及数据库对象,像:表.视图等等,DDL对这些对象和属性 ...

  2. ImportError: cannot import name 'DjangoSuitConfig'

    pip3.6 install https://github.com/darklow/django-suit/tarball/v2

  3. 方法型混淆js代码

    const fs = require('fs'); const acorn = require('acorn'); const walk = require("acorn-walk" ...

  4. 【译文】走出Java ClassLoader迷宫 Find a way out of the ClassLoader maze

    本文是一篇译文.原文:Find a way out of the ClassLoader maze 对于类加载器,普通Java应用开发人员不需要了解太多.但对于系统开发人员,正确理解Java的类加载器 ...

  5. A Survey of Visual Attention Mechanisms in Deep Learning

    A Survey of Visual Attention Mechanisms in Deep Learning 2019-12-11 15:51:59 Source: Deep Learning o ...

  6. 工具系列 | PHPSTROM 连接Docker容器 && 配置XDEBUG调试

    Docker 客户端配置 PHPSTROM 配置 选择连接 容器日志 配置Xdebug 开启Debug模式 打断点 浏览器访问该项目地址:http://wiot.frp.tinywan.top/

  7. openwrt的shell下如何访问寄存器的内容?

    答:通过devmem工具(在openwrt的make menuconfig中可以使能该工具) $ busybox devmem 0x123456

  8. 两行命令查看自己笔记本连接的wifi密码

    打开cmd.exe窗口 第一行命令 netsh wlan show profiles 可以查看所有曾经连接过的wifi 第二命令 netsh wlan show profiles "vivo ...

  9. Java13新特性 -- ZGC:取消使用未使用的内存

    在JDK 11中,Java引入了ZGC,这是一款可伸缩的低延迟垃圾收集器,但是当时只是实验性的.号称不管你开了多大的堆内存,它都能保证在 10 毫秒内释放 JVM ,不让它停顿在那.但是,当时的设计是 ...

  10. FineReport简单上手

    一.简介 FineReport是一个企业级报表制作.分析和展示工具 官网可以下载个人版进行体验学习:(windows版本设计器) https://www.finereport.com/product/ ...