The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online(2018 青岛网络预选赛)
A题 A Live Love 原题链接:https://pintia.cn/problem-sets/1036903825309761536/problems/1041155943483625472
#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<algorithm>
#include<stack>
using namespace std;
#define inf 0x3f3f3f3f
typedef long long ll;
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif // ONLINE_JUDGE
int t;int n,m;int ans1,ans2;
scanf("%d",&t);
while(t--)
{
cin>>n>>m;
n=n-m;
ans2=m;
if(m==0)
ans1=0;
else if(m<=n)
ans1=1;
else ans1=ceil(m*1.0/(n+1));
cout<<ans2<<" "<<ans1<<endl;
}
return 0;
}
C题 Halting Problem 原题链接:https://pintia.cn/problem-sets/1036903825309761536/problems/1041156042892824576
#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<algorithm>
#include<stack>
using namespace std;
#define inf 0x3f3f3f3f
typedef long long ll;
namespace IO {
const int MT = 10 * 1024 * 1024; /// 10MB 请注意输入数据的大小!!!
char IO_BUF[MT];
int IO_PTR, IO_SZ;
/// 要记得把这一行添加到main函数第一行!!!
void begin() {
IO_PTR = 0;
IO_SZ = fread (IO_BUF, 1, MT, stdin);
}
template<typename T>
inline bool scan_d (T & t) {
while (IO_PTR < IO_SZ && IO_BUF[IO_PTR] != '-' && (IO_BUF[IO_PTR] < '0' || IO_BUF[IO_PTR] > '9'))
IO_PTR ++;
if (IO_PTR >= IO_SZ) return false;
bool sgn = false;
if (IO_BUF[IO_PTR] == '-') sgn = true, IO_PTR ++;
for (t = 0; IO_PTR < IO_SZ && '0' <= IO_BUF[IO_PTR] && IO_BUF[IO_PTR] <= '9'; IO_PTR ++)
t = t * 10 + IO_BUF[IO_PTR] - '0';
if (sgn) t = -t;
return true;
}
inline bool scan_s (char s[]) {
while (IO_PTR < IO_SZ && (IO_BUF[IO_PTR] == ' ' || IO_BUF[IO_PTR] == '\n') ) IO_PTR ++;
if (IO_PTR >= IO_SZ) return false;
int len = 0;
while (IO_PTR < IO_SZ && IO_BUF[IO_PTR] != ' ' && IO_BUF[IO_PTR] != '\n')
s[len ++] = IO_BUF[IO_PTR], IO_PTR ++;
s[len] = '\0';
return true;
}
template<typename T>
void print(T x) {
static char s[33], *s1; s1 = s;
if (!x) *s1++ = '0';
if (x < 0) putchar('-'), x = -x;
while(x) *s1++ = (x % 10 + '0'), x /= 10;
while(s1-- != s) putchar(*s1);
}
template<typename T>
void println(T x) {
print(x); putchar('\n');
}
};
using namespace IO;
using namespace std;
char ins[10005];
int a[10005];
int b[10005];
bool vis[10005][300];
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif // ONLINE_JUDGE
begin();
int t;
scan_d(t);char opt[10];
int n;
int v,k;
int r;
while(t--)
{
memset(vis,0,sizeof(vis));
scan_d(n);
r=0;
int n2=n;
int cnt=1;
while(n--)
{
scan_s(opt);
if(opt[1]=='d')
{
scan_d(v);
ins[cnt]=opt[1];
a[cnt]=v;
cnt++;
}
else if(opt[1]=='e')
{
scan_d(v);
scan_d(k);
ins[cnt]=opt[1];
a[cnt]=v;
b[cnt]=k;
cnt++;
}
else if(opt[1]=='n')
{
scan_d(v);
scan_d(k);
ins[cnt]=opt[1];
a[cnt]=v;
b[cnt]=k;
cnt++;
}
else if(opt[1]=='l')
{
scan_d(v);
scan_d(k);
ins[cnt]=opt[1];
a[cnt]=v;
b[cnt]=k;
cnt++;
}
else if(opt[1]=='g')
{
scan_d(v);
scan_d(k);
ins[cnt]=opt[1];
a[cnt]=v;
b[cnt]=k;
cnt++;
}
}
int i=1;
bool f=1;char op;
while(i!=(n2+1))
{
if(i<=0||i>n2+1){f=0;break;}
op=ins[i];
if(op=='d')
{
if(!vis[i][r]){vis[i][r]=1;}
else {f=0;break;}
r=(r+a[i])%256;
}
else if(op=='e')
{if(!vis[i][r]){vis[i][r]=1;}
else {f=0;break;}
if(r==a[i]){i=b[i];continue;}
}
else if(op=='n')
{
if(!vis[i][r]){vis[i][r]=1;}
else {f=0;break;}
if(r!=a[i]){i=b[i];
continue;}
}
else if(op=='l')
{if(!vis[i][r]){vis[i][r]=1;}
else {f=0;break;}
if(r<a[i]){i=b[i];
continue;}
}
else if(op=='g')
{
if(!vis[i][r]){vis[i][r]=1;}
else {f=0;break;}
if(r>a[i]){i=b[i];
continue;}
}
i++;
}
if(f)puts("Yes");
else puts("No");
}
return 0;
}
H Traveling on the Axis 原题链接:https://pintia.cn/problem-sets/1036903825309761536/problems/1041156323504345088
队友代码:
#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <stack>
#define rep(i,n) for(int i=0;i<(n);i++)
#define mst(x,i) memset(x,i,sizeof(x))
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long ll;
const int maxn = 1e5+5;
char s[maxn];
ll c[maxn],sumc[maxn],sum0[maxn],sumcc[maxn];
int n;
void solve() {
n = strlen(s);
c[0]=0;
for(int i=1;i<n;i++) {
if(s[i]==s[i-1]) {
c[i]=1;
}else {
c[i]=0;
}
}
sumc[0]=0;
for(int i=1;i<n;i++) {
sumc[i]=sumc[i-1]+c[i];
}
if(s[0]=='0') sum0[0]=1;
else sum0[0]=0;
for(int i=1;i<n;i++) {
int f=1-(s[i]-'0');
sum0[i]=sum0[i-1]+f;
}
sumcc[0]=sumc[0];
for(int i=1;i<n;i++) {
int f=0;
if(c[i]) f=i;
sumcc[i]=sumcc[i-1]+f;
}
ll ans=0;
for(ll i=1;i<=n;i++) {
ans += i*(i+1)/2;
ans += sumcc[i-1];
ans += sum0[i-1];
}
cout<<ans<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("data.in","r",stdin);
#endif
int T;
scanf("%d",&T);
while(T--) {
scanf("%s",s);
solve();
}
}
K XOR Clique 原题链接:https://pintia.cn/problem-sets/1036903825309761536/problems/1041156503909756928
队友代码:
#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <stack>
#define rep(i,n) for(int i=0;i<(n);i++)
#define mst(x,i) memset(x,i,sizeof(x))
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long ll;
const int maxn = 1e5+5;
int a[maxn],n;
int c[64];
void solve() {
for(int i=0;i<n;i++) {
for(int j=31;j>=0;j--) {
if( (1<<j)&a[i] ) {
c[j]++;
break;
}
}
}
int ans=-1;
for(int i=0;i<32;i++) ans=max(ans,c[i]);
cout<<ans<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("data.in","r",stdin);
#endif
int T;
scanf("%d",&T);
while(T--) {
scanf("%d",&n);
memset(c,0,sizeof(c));
for(int i=0;i<n;i++) scanf("%d",&a[i]);
solve();
}
return 0;
}
The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online(2018 青岛网络预选赛)的更多相关文章
- The 2018 ACM-ICPC Asia Qingdao Regional Contest(部分题解)
摘要: 本文是The 2018 ACM-ICPC Asia Qingdao Regional Contest(青岛现场赛)的部分解题报告,给出了出题率较高的几道题的题解,希望熟悉区域赛的题型,进而对其 ...
- The 2018 ACM-ICPC Asia Qingdao Regional Contest
The 2018 ACM-ICPC Asia Qingdao Regional Contest 青岛总体来说只会3题 C #include<bits/stdc++.h> using nam ...
- ACM ICPC Central Europe Regional Contest 2013 Jagiellonian University Kraków
ACM ICPC Central Europe Regional Contest 2013 Jagiellonian University Kraków Problem A: Rubik’s Rect ...
- 2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred)
2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred) easy: ACE ...
- The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online J - Press the Button(思维)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4056 题意 有一个按钮.一个灯.一个计时器和一个计数器,每按一次按钮,计时 ...
- The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online -C:Halting Problem(模拟)
C Halting Problem In computability theory, the halting problem is the problem of determining, from a ...
- The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online Solution
A Live Love 水. #include<bits/stdc++.h> using namespace std; typedef long long ll; ; const i ...
- 2018-2019, ICPC, Asia Yokohama Regional Contest 2018 K
传送门:https://codeforces.com/gym/102082/attachments 题解: 代码: /** * ┏┓ ┏┓ * ┏┛┗━━━━━━━┛┗━━━┓ * ┃ ┃ * ┃ ━ ...
- ZOJ - 4048 Red Black Tree (LCA+贪心) The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online
题意:一棵树上有m个红色结点,树的边有权值.q次查询,每次给出k个点,每次查询有且只有一次机会将n个点中任意一个点染红,令k个点中距离红色祖先距离最大的那个点的距离最小化.q次查询相互独立. 分析:数 ...
随机推荐
- h5中的分组元素figure、figcaption、hgroup元素介绍
分组元素用于对页面中的内容进行分组. figure元素和figcaption元素 figure元素用于定义独立的流内容(图像.图表.照片.代码等),一般指一个独立的单元.figure元素的内容应该与主 ...
- mysql之存储过程基础
存储过程 procedure 可以理解为一个处理增删改,没有返回值得函数 创建存储过程的基本语法 create procedure 过程名 ([参数列表]) begin --过程体 end 存储过程主 ...
- eclipse设置字体
- 关于servlet类,继承HttpServlet,但是无法导入HttpServlet包的原因和解决方法
原因:缺少tomcat的libraries(HttpServlet对应位置在tomcat的lib中====) 解决: 1. 2. 3. 4.
- LeetCode:183.从不订购的客户
题目链接:https://leetcode-cn.com/problems/customers-who-never-order/ 题目 某网站包含两个表 Customers 表和 Orders 表.编 ...
- spring配置文件定时器
在实际工作中,经常需要使用到定时任务,很多地方都会需要这种功能,比如做数据备份.同步等操作. 今天终于抽出时间总结了一下,写一个小例子: 基本使用: spring的定时任务使用起来十分方便,只需要两步 ...
- shell运行下的写日志
tee 重定向输出到多个文件 在执行Linux命令时,我们既想把输出保存到文件中,又想在屏幕上看到输出内容,就可以使用tee命令 要注意的是:在使用管道线时,前一个命令的标准错误输出不会被tee读 ...
- (转)Java垃圾回收基本过程
本编博客内容来自oschina,是一篇译文,文中图片比较直观的介绍了JVM进行垃圾回收的过程.原文内容来自oracle官网:Java Garbage Collection Basics oschina ...
- deep_learning_Softmax()
该节课中提到了一种叫作softmax的函数,因为之前对这个概念不了解,所以本篇就这个函数进行整理,如下: 维基给出的解释:softmax函数,也称指数归一化函数,它是一种logistic函数的归一化形 ...
- cubase 音频的淡入淡出