留坑(p.254)

 #include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream> using namespace std; void setIO(const string& s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
template<typename Q> Q read(Q& x) {
static char c, f;
for(f = ; c = getchar(), !isdigit(c); ) if(c == '-') f = ;
for(x = ; isdigit(c); c = getchar()) x = x * + c - '';
if(f) x = -x;
return x;
}
template<typename Q> Q read() {
static Q x; read(x); return x;
} const int N = + ; #include<vector>
vector<int> a, b; //#define dprintf(s, arg...) fprintf(stderr, s, ##arg) void p1() {
swap(a[], a[]);
putchar('');
// dprintf("1:");
// for(unsigned i = 0; i < a.size(); i++) {
// dprintf("%d ", a[i]);
// }
// dprintf("\n");
} void p2() {
int t = a[];
a.erase(a.begin());
a.push_back(t);
putchar('');
// dprintf("2:");
// for(unsigned i = 0; i < a.size(); i++) {
// dprintf("%d ", a[i]);
// }
// dprintf("\n");
} bool ok() {
for(unsigned i = ; i < a.size(); i++) {
if(a[i] ^ b[i]) return ;
}
return ;
} int main() {
#ifdef DEBUG
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif int n;
while(read(n)) {
a.clear(), b.clear();
for(int i = ; i <= n; i++) {
a.push_back(i);
b.push_back(read<int>());
}
if(a[] == b[]) p1();
for(int i = ; i < n; i++) {//½«µÚi¸öÒƵ½×îºó
while(a[] != b[i]) p2();
if(ok()) break;
if(i != n-) while(a[] != b[i+]) p1(), p2();
p2();
}
putchar('\n');
// dprintf("\n");
} return ;
}

最新文章

  1. SQL Server 2012 新特性:FileTable
  2. IIS 7 的 500 內部錯誤
  3. java mail
  4. iOS 在任意界面 Dismiss Keyboard
  5. 最常用的Java库一览
  6. XHTML使用规范
  7. centos 安装amp 运行环境+配置虚拟地址
  8. 【HTTP】Fiddler(二) - 使用Fiddler做抓包分析
  9. Java排序算法之插入排序
  10. OpenGL Shader Key Points (2)
  11. CSS揭秘—透明边框(一)
  12. R语言最优化(多维)
  13. 使用maven整合spring+springmvc+mybatis
  14. SpringBoot thymeleaf模板页面没提示,SpringBoot thymeleaf模板插件安装
  15. tinyint、smallint、bigint、int 区别
  16. iOS DES ECB 模式加密
  17. SPREAD for Windows Forms 控制输入法
  18. Linux Mint 18.1安装nvidia驱动
  19. 前端 crypto-js aes 加解密
  20. 初识STM32标准库

热门文章

  1. 【实习记】2014-08-20实习的mini项目总结
  2. yii2源码学习笔记(十六)
  3. php 微信支付jsapi
  4. linux下VI编辑器的使用
  5. 项目管理Point
  6. bzoj 3041: 水叮当的舞步 迭代加深搜索 &amp;&amp; NOIP RP++
  7. [BZOJ 2186] [Sdoi2008] 沙拉公主的困惑 【欧拉函数】
  8. [CF Round #294 div2] E. A and B and Lecture Rooms 【树上倍增】
  9. Android ListView列表控件的简单使用
  10. c printf