Codeforces#305-C-Soldier and Cards-暴力模拟-deque
来源:互联网 发布:怪物猎人x数据库 编辑:程序博客网 时间:2024/06/02 01:25
题意:
就是用个deque模拟游戏操作
。。n太小。。直接暴力就过了
#include <cstdio>#include <cmath>#include <cstring>#include <string>#include <algorithm>#include <iostream>#include <queue>#include <deque>#include <set>#include <vector>using namespace std;int t1[15];int t2[15];deque<int> sb1;deque<int> sb2;int main(){ int n,k1,k2; int i; cin>>n; scanf("%d",&k1); for (i=1;i<=k1;i++) { scanf("%d",&t1[i]); sb1.push_back(t1[i]); } scanf("%d",&k2); for (i=1;i<=k2;i++) { scanf("%d",&t2[i]); sb2.push_back(t2[i]); } int tt=10000; int flag=0; int turn=0; while(tt--) { if (sb1.empty()||sb2.empty()) {flag=1;break;} turn++; int a1=sb1.front(); sb1.pop_front(); int a2=sb2.front(); sb2.pop_front(); if (a1>a2) { sb1.push_back(a2); sb1.push_back(a1); } else { sb2.push_back(a1); sb2.push_back(a2); } } if (flag) { if (sb1.empty()) printf("%d %d\n",turn,2); else printf("%d %d\n",turn,1); } else printf("-1\n"); return 0; }
0 0
- Codeforces#305-C-Soldier and Cards-暴力模拟-deque
- CF 546C(Soldier and Cards-deque)
- CodeForces 546C Soldier and Cards(队列模拟)
- codeforces #304 546 C. Soldier and Cards() (模拟)
- CodeForces 546C Soldier and Cards(数据结构模拟)
- #codeforces 546C# Soldier and Cards (模拟)
- Soldier and Cards(Problem - 546C - Codeforces)
- CodeForces-546C-Soldier and Cards
- 【codeforces 546C】Soldier and Cards
- C. Soldier and Cards
- Codeforces 546C Soldier and Cards【模拟】【期末考试全突击啊T T 】
- Codeforces Round #304 (Div. 2)C. Soldier and Cards(STL+模拟)
- Codeforces Round #304 (Div. 2) C. Soldier and Cards —— 模拟题,队列
- Codeforces Round #304 (Div. 2)-C. Soldier and Cards-简单模拟
- Codeforces Round #304 (Div. 2) C Soldier and Cards
- Codeforces - 546C. Soldier and Cards- Java题解
- CodeForces 546C Soldier and Cards (队列)
- CF 546C Soldier and Cards
- 日志:每个软件工程师应该知道的关于实时数据的统一
- cookie的基本使用
- html属性
- cocoaPods的配置与使用
- 【Web Design】课堂笔记
- Codeforces#305-C-Soldier and Cards-暴力模拟-deque
- 【黑马程序员】【Foundation框架】Automatic Reference Count(ARC)
- LA3357 Pinary
- FileUtils
- hdu 1556 Color the ball
- HDU 2203 亲和串
- SQLite的优化方案
- mysql宽字符注入
- SQLite 按照日期分组