Problem H. Horrible Truth

Time Limit: 1 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/gym/100610

Description

In a Famous TV Show “Find Out” there are n characters and only one Horrible Truth. To make the series breathtaking all way long, the screenplay writer decided that every episode should show exactly one important event. There are three types of the important events in this series: • character A finds out the Truth; • character A finds out that the other character B knows the Truth; • character A finds out that the other character B doesn’t know the Truth. Initially, nobody knows the Truth. All events must be correct, and every fact found out must be true. If some character finds out some fact, she cannot find it out once again. Moreover, to give the audience some sense of action, the writer does not want an episode to show the important event of the same type as in the previous episode. Your task is to determine the maximal possible number of episodes in the series and to create an example of a screenplay plan.

Input

The only line of the input contains a single integer n — the number of characters in the TV show (1 ≤ n ≤ 100).

Output

In the first line of the output file output a single integer k — the maximal possible number of episodes in the series. Then write k lines, each containing a description of an episode. For the episode in which character A (characters are numbered 1 through n) finds out the Truth, write the line “A 0”. For an episode in which character A finds out that character B knows the Truth, write the line “A B”. Similarly, for an episode in which character A finds out that character B doesn’t know the Truth, write the line “A -B”. If there are several plans providing the maximal possible number of episodes, output any one of them.

Sample Input

3

Sample Output

13 2 -1 1 0 2 1 1 -2 3 1 3 -2 2 0 1 2 1 -3 3 2 2 -3 3 0 1 3

HINT

 

题意

无良电视剧公司要来拍电视剧了

每集演一个故事,分别是叫做A知道,B知道A知道,B知道A不知道

要求每个人都不能在两集内做同样的事情

不能连续两集都是知道,或者知道别人知道,或者知道别人不知道

要求你合乎逻辑的情况下,最多演多少集

题解:

观察样例可以,第一回合嘲讽一下别人,第二回合就让人知道,然后就来回知道别人知道和知道别人不知道这样就好了……

瞎搞……

代码:

  1. //qscqesze
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <ctime>
  6. #include <iostream>
  7. #include <algorithm>
  8. #include <set>
  9. #include <bitset>
  10. #include <vector>
  11. #include <sstream>
  12. #include <queue>
  13. #include <typeinfo>
  14. #include <fstream>
  15. #include <map>
  16. #include <stack>
  17. typedef long long ll;
  18. using namespace std;
  19. //freopen("D.in","r",stdin);
  20. //freopen("D.out","w",stdout);
  21. #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
  22. #define maxn 110000
  23. #define mod 1001
  24. #define eps 1e-9
  25. #define pi 3.1415926
  26. int Num;
  27. //const int inf=0x7fffffff; //§ß§é§à§é¨f§³
  28. const ll inf=;
  29. inline ll read()
  30. {
  31. ll x=,f=;char ch=getchar();
  32. while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
  33. while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
  34. return x*f;
  35. }
  36. //*************************************************************************************
  37.  
  38. map< pair<int,int> ,int> H;
  39. vector<pair<int,int> > V;
  40. int main()
  41. { // horrible.out
  42. freopen("horrible.in","r",stdin);
  43. freopen("horrible.out","w",stdout);
  44. int n=read();
  45. int tot=;
  46. if(n==)
  47. {
  48. printf("1\n");
  49. printf("1 0\n");
  50. return ;
  51. }
  52. V.push_back(make_pair(,-));
  53. for(int i=;i<=n;i++)
  54. {
  55. V.push_back(make_pair(i,));
  56. int ttt = ;
  57. int flag = ;
  58.  
  59. while(flag)
  60. {
  61. flag=;
  62. ttt++;
  63. if(ttt%==)
  64. {
  65. flag=;
  66. for(int ii=;ii<=n;ii++)
  67. {
  68. if(i==ii)
  69. continue;
  70. if(H[make_pair(ii,i)])
  71. continue;
  72. H[make_pair(ii,i)]=;
  73. V.push_back(make_pair(ii,i));
  74. flag=;
  75. break;
  76. }
  77. }
  78. else
  79. {
  80. flag=;
  81. for(int jj=i+;jj<=n;jj++)
  82. {
  83. for(int ii=;ii<=n;ii++)
  84. {
  85. if(ii==jj)
  86. continue;
  87. if(H[make_pair(ii,-jj)])
  88. continue;
  89. H[make_pair(ii,-jj)]=;
  90. V.push_back(make_pair(ii,-jj));
  91. flag=;
  92. break;
  93. }
  94. if(flag)
  95. break;
  96. }
  97. }
  98. }
  99. }
  100. printf("%d\n",V.size());
  101. for(int i=;i<V.size();i++)
  102. printf("%d %d\n",V[i].first,V[i].second);
  103.  
  104. }

Codeforces Gym 100610 Problem H. Horrible Truth 瞎搞的更多相关文章

  1. Codeforces Gym 100610 Problem A. Alien Communication Masterclass 构造

    Problem A. Alien Communication Masterclass Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codefo ...

  2. Codeforces Gym 100610 Problem K. Kitchen Robot 状压DP

    Problem K. Kitchen Robot Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10061 ...

  3. Codeforces Gym 100610 Problem E. Explicit Formula 水题

    Problem E. Explicit Formula Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...

  4. Codeforces Gym 100342H Problem H. Hard Test 构造题,卡迪杰斯特拉

    Problem H. Hard TestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...

  5. Gym 100531H Problem H. Hiking in the Hills 二分

    Problem H. Hiking in the Hills 题目连接: http://codeforces.com/gym/100531/attachments Description Helen ...

  6. codeforces Gym 100187L L. Ministry of Truth 水题

    L. Ministry of Truth Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/p ...

  7. Codeforces Gym 100342J Problem J. Triatrip 求三元环的数量 bitset

    Problem J. Triatrip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...

  8. Codeforces Gym 100342C Problem C. Painting Cottages 转化题意

    Problem C. Painting CottagesTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/10 ...

  9. Codeforces Gym 100342C Problem C. Painting Cottages 暴力

    Problem C. Painting CottagesTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1 ...

随机推荐

  1. innodb buffer pool

    add page to flush list buffer pool中的page,有三种状态: l  free:      当前page未被使用 l  clean:    当前page被使用,对应于数 ...

  2. Selenium2Library系列 keywords 之 _SelectElementKeywords 之 list_should_have_no_selections(self, locator)

    def list_should_have_no_selections(self, locator): """Verifies select list identified ...

  3. ubuntu安装nginx+php

    1.安装nginx aptitude search nginx sudo apt-get install nginx 2.安装php sudo apt-get install php5 sudo ap ...

  4. js中的String数据类型

    string中包含一些特殊的字符字面量,又叫转义序列,\n 意思是换行,\t 意为制表,\b意为空格,\r回车,\\斜杠. 1.ECMAScript中字符串是不可变的. 2.转换字符串的方法:toSt ...

  5. 《Genesis-3D开源游戏引擎完整实例教程-2D射击游戏篇01:播放序列动画》

    1.播放序列动画 系列动画播放概述 2D游戏中的动画系统,不同于3D游戏.3D游戏中,角色美术资源不仅包含角色模型的,还包括角色的贴图和动作等,模型本身自带角色的动作动画效果.2D游戏中,角色美术资源 ...

  6. <Chapter 2>2-1-1.安装Python SDK

    App Engine包含两个Python运行时环境:一个基于Python2.5的传统环境,以及一个运行Python2.7的新环境.这个新环境不仅仅是有一个轻微的新版本的Python解释器.主要是,这个 ...

  7. boosting和bagging

    首先来说明一下bootstraps:可以把它认为是一种有放回的抽样方法. bagging:boostraps aggregating(汇总) boosting:Adaboot (Adaptive Bo ...

  8. linux appear packet loss solution

    故障排查: 早上突然收到nagios服务器check_icmp的报警,报警显示一台网站服务器的内网网络有问题.因为那台服务器挂载了内网的NFS,因此内网的网络就采用nagios的check_icmp来 ...

  9. Cocos2dx-截屏并设置图片尺寸

    猴子原创,欢迎转载.转载请注明: 转载自Cocos2D开发网–Cocos2Dev.com,谢谢! 原文地址: http://www.cocos2dev.com/?p=522 前几天添加微信图片分享的时 ...

  10. Spring+Quartz 整合一:常规整合

    步骤一: 定时任务需要一个配置文件(spring-mvc-timeTask.xml 随便起名),将其在web.xml中加载 <context-param> <param-name&g ...