Codeforces Gym 100610 Problem H. Horrible Truth 瞎搞
2015-09-05 18:34
447 查看
[b]Problem H. Horrible Truth[/b]
Time Limit: 1 Sec
Memory Limit: 256 MB
无良电视剧公司要来拍电视剧了
每集演一个故事,分别是叫做A知道,B知道A知道,B知道A不知道
要求每个人都不能在两集内做同样的事情
不能连续两集都是知道,或者知道别人知道,或者知道别人不知道
要求你合乎逻辑的情况下,最多演多少集
题解:
观察样例可以,第一回合嘲讽一下别人,第二回合就让人知道,然后就来回知道别人知道和知道别人不知道这样就好了……
瞎搞……
代码:
Time Limit: 1 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/gym/100610Description
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
3Sample 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 3HINT
题意无良电视剧公司要来拍电视剧了
每集演一个故事,分别是叫做A知道,B知道A知道,B知道A不知道
要求每个人都不能在两集内做同样的事情
不能连续两集都是知道,或者知道别人知道,或者知道别人不知道
要求你合乎逻辑的情况下,最多演多少集
题解:
观察样例可以,第一回合嘲讽一下别人,第二回合就让人知道,然后就来回知道别人知道和知道别人不知道这样就好了……
瞎搞……
代码:
//qscqesze #include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <bitset> #include <vector> #include <sstream> #include <queue> #include <typeinfo> #include <fstream> #include <map> #include <stack> typedef long long ll; using namespace std; //freopen("D.in","r",stdin); //freopen("D.out","w",stdout); #define sspeed ios_base::sync_with_stdio(0);cin.tie(0) #define maxn 110000 #define mod 1001 #define eps 1e-9 #define pi 3.1415926 int Num; //const int inf=0x7fffffff; //§ß§é§à§é¨f§³ const ll inf=999999999; inline ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } //************************************************************************************* map< pair<int,int> ,int> H; vector<pair<int,int> > V; int main() { // horrible.out freopen("horrible.in","r",stdin); freopen("horrible.out","w",stdout); int n=read(); int tot=0; if(n==1) { printf("1\n"); printf("1 0\n"); return 0; } V.push_back(make_pair(2,-1)); for(int i=1;i<=n;i++) { V.push_back(make_pair(i,0)); int ttt = 0; int flag = 1; while(flag) { flag=0; ttt++; if(ttt%2==1) { flag=0; for(int ii=1;ii<=n;ii++) { if(i==ii) continue; if(H[make_pair(ii,i)]) continue; H[make_pair(ii,i)]=1; V.push_back(make_pair(ii,i)); flag=1; break; } } else { flag=0; for(int jj=i+1;jj<=n;jj++) { for(int ii=1;ii<=n;ii++) { if(ii==jj) continue; if(H[make_pair(ii,-jj)]) continue; H[make_pair(ii,-jj)]=1; V.push_back(make_pair(ii,-jj)); flag=1; break; } if(flag) break; } } } } printf("%d\n",V.size()); for(int i=0;i<V.size();i++) printf("%d %d\n",V[i].first,V[i].second); }
相关文章推荐
- Training Neural Networks: Q&A with Ian Goodfellow, Google
- 浏览器缓存机制
- (5)jvm垃圾回收器相关垃圾回收算法
- 建立高效人际关系的五大方法
- OK6410裸机开发之Ubuntu上Openocd环境搭建
- C#设计模式(1)——单例模式
- 第477天 继续学习伽马的《设计模式》
- 软工视频总结
- final变量
- Opencv贴图的两种方式
- 使用nginx+lua实现自己的logserver | 星期八的博客 web & game
- 让nginx支持文件上传的几种模式 - jlins - 博客园
- Effective STL 第六条 当心C++编译器最烦人的分析机制
- 【java基础】J2SE视频总结
- Android中的Looper,MessageQueue,Handler的理解
- poj 2987 Firing 【最大权闭合图 输出点数和最大权值】
- Android - Looper / Handler / Message
- Java虚拟机(2)自动内存管理机制
- 利用nginx+lua+memcache实现灰度发布
- LA3938-Ray, Pass me the dishes!--动态最大连续区间和(线段树+前后缀数和组)