Codeforces Beta Round #59 (Div. 2)
Codeforces Beta Round #59 (Div. 2)
http://codeforces.com/contest/63
A
- #include<bits/stdc++.h>
- using namespace std;
- #define lson l,mid,rt<<1
- #define rson mid+1,r,rt<<1|1
- #define sqr(x) ((x)*(x))
- #define pb push_back
- #define eb emplace_back
- #define maxn 1000006
- #define rep(k,i,j) for(int k=i;k<j;k++)
- typedef long long ll;
- typedef unsigned long long ull;
- struct sair{
- string name,v;
- }a[];
- int main(){
- #ifndef ONLINE_JUDGE
- freopen("input.txt","r",stdin);
- #endif
- std::ios::sync_with_stdio(false);
- int n;
- cin>>n;
- rep(i,,n+){
- cin>>a[i].name>>a[i].v;
- }
- rep(i,,n+){
- if(a[i].v=="rat"){
- cout<<a[i].name<<endl;
- }
- }
- rep(i,,n+){
- if(a[i].v=="woman"||a[i].v=="child"){
- cout<<a[i].name<<endl;
- }
- }
- rep(i,,n+){
- if(a[i].v=="man"){
- cout<<a[i].name<<endl;
- }
- }
- rep(i,,n+){
- if(a[i].v=="captain"){
- cout<<a[i].name<<endl;
- }
- }
- }
B
暴力模拟即可
- #include<bits/stdc++.h>
- using namespace std;
- #define lson l,mid,rt<<1
- #define rson mid+1,r,rt<<1|1
- #define sqr(x) ((x)*(x))
- #define pb push_back
- #define eb emplace_back
- #define maxn 1000006
- #define rep(k,i,j) for(int k=i;k<j;k++)
- typedef long long ll;
- typedef unsigned long long ull;
- int n,k;
- int a[];
- int book[];
- int main(){
- #ifndef ONLINE_JUDGE
- // freopen("input.txt","r",stdin);
- #endif
- std::ios::sync_with_stdio(false);
- cin>>n>>k;
- int ans=;
- rep(i,,n+){
- cin>>a[i];
- }
- a[]=-0x3f3f3f3f;
- sort(a,a+n+);
- int flag=;
- while(flag){
- flag=;
- rep(i,,n+){
- if(a[i]<k)
- if(a[i]!=a[i-]){
- book[i]++;
- flag=;
- }
- }
- rep(i,,n+) a[i]+=book[i],book[i]=;
- sort(a,a+n+);
- ans+=flag;
- }
- cout<<ans<<endl;
- }
C
枚举1-9999的数,然后一个个判断,看看有几个符合条件
- #include<bits/stdc++.h>
- using namespace std;
- #define lson l,mid,rt<<1
- #define rson mid+1,r,rt<<1|1
- #define sqr(x) ((x)*(x))
- #define pb push_back
- #define eb emplace_back
- #define maxn 1000006
- #define rep(k,i,j) for(int k=i;k<j;k++)
- typedef long long ll;
- typedef unsigned long long ull;
- int n;
- struct sair{
- int a,b,c;
- }q[];
- int main(){
- #ifndef ONLINE_JUDGE
- // freopen("input.txt","r",stdin);
- #endif
- // std::ios::sync_with_stdio(false);
- cin>>n;
- rep(i,,n) {
- cin>>q[i].a>>q[i].b>>q[i].c;
- }
- int x,y,z;
- int ans,num=;
- rep(i,,){
- int tmp=i;
- int a,b,c,d;
- a=tmp%,tmp/=;
- b=tmp%,tmp/=;
- c=tmp%,tmp/=;
- d=tmp%;
- if(a==b||a==c||a==d||b==c||b==d||c==d) continue;
- int flag=;
- rep(j,,n){
- x=,y=,z;
- tmp=q[j].a;
- z=tmp%;
- if(a==z) x++;
- if(b==z) y++;
- if(c==z) y++;
- if(d==z) y++;
- tmp/=;
- z=tmp%;
- if(b==z) x++;
- if(a==z) y++;
- if(c==z) y++;
- if(d==z) y++;
- tmp/=;
- z=tmp%;
- if(c==z) x++;
- if(b==z) y++;
- if(a==z) y++;
- if(d==z) y++;
- tmp/=;
- z=tmp%;
- if(d==z) x++;
- if(b==z) y++;
- if(c==z) y++;
- if(a==z) y++;
- if(x!=q[j].b||y!=q[j].c){
- flag=;
- break;
- }
- }
- if(flag){
- num++;
- ans=i;
- }
- }
- if(num==) cout<<"Incorrect data"<<endl;
- else if(num==) printf("%04d\n",ans);
- else cout<<"Need more data"<<endl;
- }
D
通过多次模拟可以发现,只要走S形即可
- #include<bits/stdc++.h>
- using namespace std;
- #define lson l,mid,rt<<1
- #define rson mid+1,r,rt<<1|1
- #define sqr(x) ((x)*(x))
- #define pb push_back
- #define eb emplace_back
- #define maxn 1000006
- #define rep(k,i,j) for(int k=i;k<j;k++)
- typedef long long ll;
- typedef unsigned long long ull;
- int field[][];
- int main(){
- #ifndef ONLINE_JUDGE
- // freopen("input.txt","r",stdin);
- #endif
- std::ios::sync_with_stdio(false);
- int a,b,c,d,n;
- cin >> a >> b >> c >> d >> n;
- for (int i=; i<; i++) {
- for (int j=; j<; j++) {
- field[i][j]=;
- }
- }
- int party[]={};
- for (int i=; i<n; i++) {
- cin >> party[i];
- }
- for (int i=; i<max(b,d); i++) {
- for (int j=; j<a+c; j++) {
- if ((j<a&&i>=b)||(j>=a&&i>=d))field[i][j]='.';
- }
- }
- int x=,y=,dx=;
- if (((b>d)&&(d%==))||((d>b)&&(b%==))){
- x=a+c-;dx=-;
- }
- for (int i=; i<n; i++) {
- for (int j=; j<party[i]; j++) {
- field[y][x]='a'+i;
- if (x+dx<||x+dx>=a+c||field[y][x+dx]=='.') {
- dx*=-;
- y++;
- } else {
- x+=dx;
- }
- }
- }
- cout << "YES" << endl;
- for (int i=; i<max(b,d); i++) {
- for (int j=; j<a+c; j++) {
- cout << char(field[i][j]);
- }
- cout << endl;
- }
- }
E
一种类似博弈的题目,用状压表示每一种情况,然后搜索,找出Karlsson的必胜路径,找不到的话就是必败
- #include<bits/stdc++.h>
- using namespace std;
- #define lson l,mid,rt<<1
- #define rson mid+1,r,rt<<1|1
- #define sqr(x) ((x)*(x))
- #define pb push_back
- #define eb emplace_back
- #define maxn 1000006
- #define rep(k,i,j) for(int k=i;k<j;k++)
- typedef long long ll;
- typedef unsigned long long ull;
- const int N=,S=<<;
- int Next[][N]={{,,,,,,,N,,,,,N,,,,N,N,N},
- {,,N,,,,N,,,,,N,,,,N,,,N},
- {,,,,,,,,,,,N,,,,N,N,N,N}};
- int dp[S],status=;
- int dfs(int now){
- if(dp[now]) return dp[now];
- rep(t,,){
- rep(i,,N){
- int tmp=now,p=i;
- while(tmp&(<<p)){
- tmp^=(<<p);
- if(dfs(tmp)==){
- return dp[now]=;
- }
- p=Next[t][p];
- }
- }
- }
- return dp[now]=;
- }
- int main(){
- #ifndef ONLINE_JUDGE
- freopen("input.txt","r",stdin);
- #endif
- std::ios::sync_with_stdio(false);
- char ch;
- rep(i,,N){
- cin>>ch;
- if(ch=='.'||ch=='O'){
- if(ch=='O'){
- status+=(<<i);
- }
- }
- else{
- i--;
- }
- }
- int flag=dfs(status);
- if(flag==) cout<<"Karlsson"<<endl;
- else cout<<"Lillebror"<<endl;
- }
Codeforces Beta Round #59 (Div. 2)的更多相关文章
- Codeforces Beta Round #55 (Div. 2)
Codeforces Beta Round #55 (Div. 2) http://codeforces.com/contest/59 A #include<bits/stdc++.h> ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
- Codeforces Beta Round #73 (Div. 2 Only)
Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...
随机推荐
- Firefox What's New 太难找了
Firefox每次更新版本,不知道更新了什么,找不到Waht‘s New,做个记录! 1.点击mozilla下拉 2.最左侧 MOZILLA>SUPPORT>Firefox 3.https ...
- html to docx
public static void main(String[] args) throws Exception{ //创建 POIFSFileSystem 对象 POIFSFileSystem poi ...
- WDA-5-VIEW视图切换
这一部分介绍同一窗口下不同视图之间的链接跳转. 前提:完成上一步骤MAIN视图ALV显示. 1.效果展示 点击ALV物料下划线链接,页面跳转到物料明细页面. 2.实现过程 基于上一步骤在MAIN页面显 ...
- Win2008R2配置WebDeploy(转)
一.配置服务器 1.安装管理服务 2.点击管理服务进行配置 3.安装WebDeploy 3.1通过离线安装包方式安装: https://www.iis.net/downloads/microsoft/ ...
- zookeeper windows7下集群搭建
模拟分布式环境!!! 搞了好几天,各种错误!!终于成功了. 环境: windows7 /centos/xsheel 安装了三个虚拟机... 1.下载zookeeper http://archi ...
- Spring AOP demo 和获取被CGLIB代理的对象
本文分为两部分:1)给出Spring AOP的一个例子(会使用CGLIB代理):2)给出获取被CGLIB代理的原始对象. 1.Spring AOP Demo 这部分参考了博文(http://www.v ...
- 转: JQuery this和$(this)的区别及获取$(this)子元素对象的方法
1.JQuery this和$(this)的区别 相信很多刚接触JQuery的人,很多都会对$(this)和this的区别模糊不清,那么这两者有什么区别呢? 首先来看看JQuery中的 $() 这 ...
- 讲一讲Servlet和JSP的关系
Test.jsp在运行时首先被解析成一个java类Test_jsp.java,该类继承于org.apache.jasper.runtime.HtppJspBase类,而Http又是继承HttpServ ...
- Android Studio 3.0.1 又见恶心爆的bug。。。xiete
写了个AIDL的东西,结果一直编译不通过: Error:Execution failed for task ':app:compileDebugAidl'. > java.io.IOExcept ...
- 一个关于EasyUI超恶心的BUG。。。Cannot read property 'options' of undefined
控制台Console抛出的异常: jquery.easyui.min.js:9148 Uncaught TypeError: Cannot read property 'options' of und ...