CodeForces 202B Brand New Easy Problem
来源:互联网 发布:绝境求生画面优化补丁 编辑:程序博客网 时间:2024/06/05 22:50
题意很简单,就是问给出的n个单词的句子经过全排列顺序能否和下面m句句子中某句所相同的单词顺序相同
如果会string类 容器还有algorithm中next_permutation就很简单了
#include <iostream>#include <string.h>#include <stdio.h>#include <queue>#include <vector>#include <string>#include <algorithm>using namespace std;const int INF=1000000;int getInt(){ char ch=getchar(); while(ch<'0'||ch>'9')ch=getchar(); int num=0; while(ch>='0'&&ch<='9'){ num=num*10+ch-'0'; ch=getchar(); } return num;}int n,m;string s[5];vector <string> str[33];int a[5];int judge(int i){ int j=0,len=0; while(len<str[i].size()&&j<n) { if(str[i][len]==s[a[j]]) j++; len++; } if(j==n) return true; return false;}int zidian(){ int sum=0; for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { if(a[i]>a[j]) sum++; } } return sum;}int main(){ int i,j,ans,res,pos,vis,v; cin>>n; for(i=0;i<n;i++) cin>>s[i]; cin>>m; for(i=0;i<m;i++) { cin>>ans; str[i].resize(ans); for(j=0;j<ans;j++) cin>>str[i][j]; } int flag=0; pos=INF; for(i=0;i<m;i++) { res=INF; for(j=0;j<n;j++) a[j]=j; do{ if( judge(i) ) res=min(res,zidian()); }while(next_permutation(a,a+n)); if(res<pos) { pos=res; vis=i; flag=1; } } if(!flag) cout<<"Brand new problem!\n"; else { cout<<vis+1<<endl; int p=n*(n-1)/2-pos+1; cout<<"[:"; for(i=0;i<p;i++) cout<<"|"; cout<<":]\n"; } return 0;}
0 0
- CodeForces 202B Brand New Easy Problem
- codeforces 202B Brand New Easy Problem
- Codeforces 202B Brand New Easy Problem(模拟)
- cf B. Brand New Easy Problem
- codeforces 278B New Problem
- codeforces 278B New Problem 字符串查找
- 状态压缩DP codeforces 244 Problem C. The Brand New Function 和 codeforces 165 E. Compatible Numbers
- B - An easy problem
- B - An easy problem
- B - An easy problem
- Codeforces Round #170 (Div. 2) B. New Problem
- Codeforces Round #150 (Div. 1) A. The Brand New Function
- Codeforces Round #150 (Div. 2) C. The Brand New Function
- CodeForces 243A|The Brand New Function|位运算
- B. New Problem
- Problem - 216B - Codeforces
- Problem - 218B - Codeforces
- codeforces problem/408/B
- 语音编解码芯片AMBE2000中文手册
- 第三章 少量(无)标记增强现实——Chapter 3:Marker-less Augmented Reality
- mysql将查询部分数据导出到外部文件的脚本,文件格式替换
- 使用CXF开发WebService客户端
- 一台电脑同时运行多个tomcat配置方法
- CodeForces 202B Brand New Easy Problem
- 使用临时表在list和reapter之间做数据的传递(双击view,数据进入到repeater中,点击reapter中的删除按钮进行删除)
- android Theme使用三
- Arrays.sort()排序
- Web Service入门
- 远程桌面连接配置
- System.Runtime.InteropServices.COMException 检索COM类工厂中CLSID{xxxxxxxxx}的组件时失败解决方法
- ControlTemplate和DataTemplate的区别
- net重量 cross重量