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次查询相互独立. 分析:数 ...
随机推荐
- python-day6(正式学习)
流程控制之while循环 语法 循环就是一个重复的过程,人需要重复做某项工作,那么计算机也一样.当ATM验证失败,那么计算机就会让我们再输入一次密码.这时候我们说的循环就是while循环,while循 ...
- peewee无外键连接
# 参考:https://blog.csdn.net/weixin_34273479/article/details/87587183 res = Name.select(Name, User.xxx ...
- Zend 3.3.0安装 ZendOptimizer 3.3.0 for Windows 稳定版 下载
用的某php网站系统今天打开时乱码了(zend 200407...),但phpmyadmin能正常使用: 搜索下,重新安装zend可以解决,系统上原来的版本是Zend 3.3.0:下了个,安装后果然把 ...
- java文件上传复制等功能
package com.sitech.message.controller.task;import java.io.File;//引入类 import java.io.FileInputStream; ...
- 不再显示广告案例(php操作cookie)
1,页面简单结构搭建 ad.html <!DOCTYPE html> <html lang="en"> <head> <meta char ...
- string字符串长度和字节长度问题
string str = "abcdef 安安安"; int i = str.Length; byte[] bt = System.Text.Encoding.Default.Ge ...
- 斐波那契数列(js)
//斐波那契数列:后一个数等于前面两个数的和 //0,1,1,2,3,5,8,13,21.... let readline = require("readline-sync"); ...
- js多语言切换demo
网站为了国际化的需要,会使用到语言包,案例如下图. 这次尝试用js来打语言包,用到了插件 jquery.i18n.properties ,很明显,使用这个插件需要先加载jquery. 代码布局结构 ...
- go语言中获取变量类型的三种方法
package main import ( "fmt" "reflect" ) func main() { var num float64 = 3.14 // ...
- mac 下的操作
nodejs在Mac下的卸载 在 node 官网上下载的安装包,用安装包安装的node.应该可以用一下命令行卸载: 在终端输入以下命令: sudo rm -rf /usr/local/{bin/{no ...