AIM Tech Round 4 (Div. 2)ABCD
这一场真的是血崩,a,b都被hack,还好结束前重交都过了
A:题意:找出得到k个不同的字符,所要更改的最小字符数
题解:首先如果k>字符串长度,直接impossible,然后直接记录一下不重复的有多少个,如果不重复的个数比k小,输出k-不重复的个数,否则输出0(就是这里被hack)
#include<bits/stdc++.h>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f3f3f; bool vis[];
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n;
string s;
cin>>s>>n;
int ans=;
for(int i=;i<s.size();i++)
{
if(!vis[s[i]-'a'])
{
vis[s[i]-'a']=;
ans++;
}
}
if(n>s.size())cout<<"impossible"<<endl;
else cout<<max(,n-ans)<<endl;
return ;
}
/******************** ********************/
A
B:题意:给一个n*m的数字(0,1)矩阵,求能组成团的有多少(每一个团里元素值相同,而且在同一行或同一列)
题解:对每一行和每一列计算1的个数(k),这样每一行(列)里1构成的团有(1<<k)-1个(可以分1,2,,,k)来列举出,0构成的有(1<<(m(列就是n)-k))-1
但是最大到了(1<<50)会爆longlong(就是这里被hack了)(后来实在脑残了直接改写成python交上去过了,之后发现原来把1改成1ll就能过了)
n,m = input().strip().split()
n = int(n)
m = int(m)
a = [([0]*50) for i in range(50)]
for i in range(n):
p=input()
a[i] = p.split(' ')
ans = 0
for i in range(n):
k = 0
for j in range(m):
if a[i][j] == '':
k = k+1
ans=ans+2**k-1+2**(m-k)-1
for i in range(m):
k = 0
for j in range(n):
if a[j][i] == '':
k = k+1
ans=ans+2**k-1+2**(n-k)-1
print(ans-n*m)
B---python
#include<bits/stdc++.h>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f; int a[N][N];
int main()
{
ios::sync_with_stdio(false);
cin.tie();
ll n,m;
cin>>n>>m;
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
cin>>a[i][j];
ll ans=-n*m;
for(int i=;i<=n;i++)
{
ll k=;
for(int j=;j<=m;j++)
if(a[i][j]==)
k++;
ans+=(1ll<<k)-;
ans+=(1ll<<(m-k))-;
}
for(int i=;i<=m;i++)
{
ll k=;
for(int j=;j<=n;j++)
if(a[j][i]==)
k++;
ans+=(1ll<<k)-;
ans+=(1ll<<(n-k))-;
}
cout<<ans<<endl;
return ;
}
/******************** ********************/
B---c++
C:题意:给定一个数列,要求对其中某些数排序,排完序之后放在对应的位置,然后每个数最多排一次,要求排的次数最多,而且排完之后整个数列递增
题解:先对其排序,按照下标的顺序去找到最小的那个团,比如3 1 2,3应该放在2的位置,那么就再取2,2应该放在1的位置那么取1,则最小团就是1,2,3
#include<bits/stdc++.h>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f3f3f; int a[N],b[N];
bool vis[N];
map<int,int>m;
vector<int>v[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n;
cin>>n;
for(int i=;i<=n;i++)
{
cin>>b[i];
a[i]=b[i];
}
sort(b+,b++n);
for(int i=;i<=n;i++)m[b[i]]=i;
int cnt=;
for(int i=;i<=n;i++)
{
if(!vis[i])
{
++cnt;
int p=i;
while(m[a[p]]!=i){
vis[m[a[p]]]=;
v[cnt].push_back(m[a[p]]);
p=m[a[p]];
}
v[cnt].push_back(m[a[p]]);
}
}
cout<<cnt<<endl;
for(int i=;i<=cnt;i++)
{
cout<<v[i].size();
for(int j=;j<v[i].size();j++)
cout<<" "<<v[i][j];
cout<<endl;
}
return ;
}
/******************** ********************/
C
D:题意:交互题,给定一个链表,每次查询时会给你当前结点的价值和下一个节点的坐标,询问的是坐标,链表价值递增,要求找到最小的大于等于x的那个价值,且询问次数不超过2000次
题解:先生成一个随机数组,然后访问前1600个,找到最大的小于等于x的那个坐标,然后沿着那个坐标走,就能得到结果了(刚开始直接访问了不随机的前1500个导致wa了,然后随机数种子忘了写又wa了)srand(time(NULL));
#include<bits/stdc++.h>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f3f3f; int main()
{
srand(time(NULL));
ios::sync_with_stdio(false);
cin.tie();
int st,n,x;
cin>>n>>st>>x;
vector<int>v;
for(int i=;i<n;i++)
v.push_back(i+);
random_shuffle(v.begin(),v.end());
int ans=-,p=st;
for(int i=; i<min(n,); i++)
{
cout<<"? "<<v[i]<<endl;
cout.flush();
int v,id;
cin>>v>>id;
if(v>ans&&v<=x)
{
p=id;
ans=v;
}
}
while(p!=-&&ans<x)
{
cout<<"? "<<p<<endl;
cin>>ans>>p;
}
if(ans<x)ans=-;
cout<<"! "<<ans<<endl;
cout.flush();
return ;
}
/******************** ********************/
D
AIM Tech Round 4 (Div. 2)ABCD的更多相关文章
- codeforce AIM tech Round 4 div 2 B rectangles
2017-08-25 15:32:14 writer:pprp 题目: B. Rectangles time limit per test 1 second memory limit per test ...
- AIM Tech Round 3 (Div. 2)
#include <iostream> using namespace std; ]; int main() { int n, b, d; cin >> n >> ...
- AIM Tech Round 3 (Div. 2) A B C D
虽然打的时候是深夜但是状态比较好 但还是犯了好多错误..加分场愣是打成了降分场 ABC都比较水 一会敲完去看D 很快的就想出了求0和1个数的办法 然后一直wa在第四组..快结束的时候B因为低级错误被h ...
- AIM Tech Round 3 (Div. 2) B
Description Vasya takes part in the orienteering competition. There are n checkpoints located along ...
- AIM Tech Round 3 (Div. 2) A
Description Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Ko ...
- AIM Tech Round 3 (Div. 2) (B C D E) (codeforces 709B 709C 709D 709E)
rating又掉下去了.好不容易蓝了.... A..没读懂题,wa了好几次,明天问队友补上... B. Checkpoints 题意:一条直线上n个点x1,x2...xn,现在在位置a,求要经过任意n ...
- AIM Tech Round 3 (Div. 2) B 数学+贪心
http://codeforces.com/contest/709 题目大意:给一个一维的坐标轴,上面有n个点,我们刚开始在位置a,问,从a点开始走,走n-1个点所需要的最小路程. 思路:我们知道,如 ...
- AIM Tech Round 3 (Div. 2)D. Recover the String(贪心+字符串)
D. Recover the String time limit per test 1 second memory limit per test 256 megabytes input standar ...
- AIM Tech Round 4 (Div. 2)ABCD
A. Diversity time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
随机推荐
- 登录案例locustfile.py
# 保存为locustfile.py # coding=utf-8 from locust import HttpLocust, TaskSet, task ''' 实现场景:先登录(只登录一次),然 ...
- (4.14)存储:RAID在数据库存储上的应用
关键词:(4.14)存储:RAID在数据库存储上的应用 转自:http://blog.51cto.com/qianzhang/1251260 随着单块磁盘在数据安全.性能.容量上呈现出的局限,磁盘阵列 ...
- hexo+yilia页脚添加总访问量
个人博客:https://www.yuehan.online 现在博客:http://www.wangyurui.top 脚本方法使用不蒜子计数 安装脚本 要使用不蒜子(官网:http://busua ...
- python基础实例
1.在Python 语言中,对象是通过引用传递的.在赋值时,不管这个对象是新创建的,还是一个已经存在的,都是将该对象的引用(并不是值)赋值给变量. 如:x=1 1这个整形对象被创建,然后将这个对象的引 ...
- google guava libraries
google/guava Guava项目包含一些在我们自己的项目中可以依赖的Google核心库.也就是Google开源的核心库,可以由其他项目利用. 其中包括: 集合 缓存 原语的支持(primiti ...
- 常用mysql导入导出数据的命令
To export 导出指定db_name的数据: $ mysqldump -u [uname] -p[pass] db_name > db_backup.sql 导出整个库的数据: $ mys ...
- C# TreeView,递归循环数据加载到treeView1中
TblAreaBLL bll = new TblAreaBLL(); private void button1_Click(object sender, EventArgs e) { LoadData ...
- Ubuntu10.04下的使用使用华为E1750 3G模块
系 统:Ubuntu 10.04 3G模块:华为E1750 1 安装usb-modeswitch软件 E1750 无线上网卡并没有提供linux环境下的驱动程序,但我们可以通过USB模式转换来让l ...
- BFC与边距重叠详解
1.什么是BFC? 在解释 BFC 是什么之前,需要先介绍 Box.Formatting Context的概念. Box: CSS布局的基本单位Box 是 CSS 布局的对象和基本单位, 直观点来说, ...
- requests.post处理Content-Type: multipart/form-data的请求
前几天遇到一个需求,要调用一个接口发送请求,抓包之后得到的数据是这样的 上网看了一些资料得知,原来这个接口的数据是通过multipart/form-data格式传过去的,multipart/form- ...