Codeforces Round 504
(交互题真神奇,,,我自己瞎写了一发目测样例都没过去就AC了。。。)
(只出了两题的竟然没掉下蓝名真是可怕)
A:我的代码太不美观了,放个同学的(因为我是c++63分的蒟蒻所以根本不知道那些函数怎么用只能手写被hack)
这个题本身不难,坑点太多了,很囍的是我在2:13分的时候被hack了,,GG
- #include<cstdio>
- #include<iostream>
- #include<cstring>
- #include<cstdlib>
- #include<climits>
- #include<vector>
- #include<set>
- #include<cmath>
- #include<queue>
- #include<algorithm>
- using namespace std;
- int n,m;
- signed main() {
- cin>>n>>m;
- if (n > m + ) return puts("NO"), ;
- std::string s, t;
- std::cin >> s >> t;
- int star = ;
- for (auto i : s) if (i == '*') star = ;
- if (!star && s != t) return puts("NO");
- std::string pre = s.substr(, s.find('*')), suf = s.substr(s.find('*') + );
- int pres = pre.size(), sufs = suf.size();
- if (t.substr(, pres) == pre && t.substr(m - sufs) == suf) puts("YES");
- else puts("NO");
- }
B:自认非常优雅
- #include <bits/stdc++.h>
- typedef long long ll;
- using namespace std;
- ll n,k;
- int main(){
- scanf("%lld%lld",&n,&k);
- ll ans = ;
- if(k>n){
- ll tmp = k-n;
- ans = (n-tmp+)/;
- } else{
- ll tmp = k-;
- ans = (tmp-+)/;
- }
- ans =ans>?ans:;
- printf("%lld\n",ans);
- }
C:
太困了又刚补了几话狐妖又吸了冰毒 喝了冷藏的维他柠檬茶 导致一开始的思路是错的,,,还wa了两发。。。其实是个大水题
- #include <bits/stdc++.h>
- typedef long long ll;
- using namespace std;
- int n,k;
- char s[];
- int main() {
- scanf("%d%d", &n, &k);
- scanf("%s", s + );
- k/=;
- int cnt = ,cnt2=;
- for(int i=;i<=n;i++){
- if(s[i]=='(')
- cnt++;
- else
- cnt2++;
- printf("%c",s[i]);
- if(cnt==k)
- break;
- }
- cnt2 = cnt-cnt2;
- while (cnt2--){
- printf(")");
- }
- }
D:旁边哥们吐槽没读懂题,,其实我也没读懂,我是交了两发wa了之后才勉强猜对的题意,GG
题意:我语文不好啊
给你n个数,q次操作,每次操作按照从1到q的顺序 对 任意区间赋值成 那个数,第一次赋值1,第二次赋值2, n个数中为0的数可以自由变成任意数,其他数不能改变, 问 q次操作后能否得到 给定 序列,并输出序列。 自己结合样例好好读读吧,,真的挺难懂的。。
想了很多骚操作还是直接线段树好。。
我觉着只要做了这个题代码是非常好懂的,我就不细说了
- #include <bits/stdc++.h>
- typedef long long ll;
- using namespace std;
- const int N = 2e5 + ;
- int n, q;
- int a[N], vis[N],l[N],r[N],flag[N];
- int minn[*N];
- void build(int k, int l, int r) {
- if (l == r) {
- minn[k] = a[l];
- return;
- }
- int mid = (l + r) >> ;
- build(k << , l, mid);
- build(k << | , mid + , r);
- minn[k] = min(minn[k*],minn[k*+]);
- }
- void update(int k, int l, int r) {
- }
- int query(int k, int lef, int rig, int l, int r) {
- if (l <= lef && r >= rig)
- return minn[k];
- int mid = (lef + rig) / ;
- int ans = 1e9;
- if (l <= mid)
- ans = min(ans, query(k * , lef, mid, l, r));
- if (r > mid)
- ans = min(ans, query(k << | , mid + , rig, l, r));
- return ans;
- }
- int main() {
- scanf("%d%d", &n, &q);
- for (int i = ; i <= n; i++)
- scanf("%d", &a[i]);
- for (int i = ; i <= n; i++) {
- int j = i + ;
- while (j <= n && (a[j] == a[i] || a[j] == )) {
- if (a[j] == ) {
- a[j] = a[i];
- flag[j]=;
- }
- j++;
- }
- vis[a[i]] = ;
- i = j - ;
- }
- int temp = ;
- if(a[]!=&&!vis[q]){
- for(int i=;i<=n;i++){
- if(flag[i]){
- a[i]=q;
- vis[q]=;
- break;
- }
- }
- if(!vis[q]) {
- printf("NO\n");
- return ;
- }
- }
- if (a[] == ) {
- if (!vis[q]) {
- temp = q;
- } else {
- for (int i = ; i <= n; i++) {
- if (a[i] != ) {
- temp = a[i];
- break;
- }
- }
- }
- for (int i = ; i <= n; i++) {
- if (a[i] == )
- a[i] = temp;
- }
- }
- for(int i=;i<=n;i++){
- if(l[a[i]]==)
- l[a[i]]=i;
- r[a[i]]=i;
- }
- build(,,n);
- for(int i=;i<=q;i++){
- if(l[i]==)
- continue;
- if(query(,,n,l[i],r[i])<i){
- printf("NO\n");
- return ;
- }
- }
- printf("YES\n");
- for(int i=;i<=n;i++){
- printf("%d ",a[i]);
- }
- }
E : 第一次做交互题,,瞎写一发入魂,,(当然不是昨晚上。。。)
感觉就是个贪心啊,,我也不知道为啥我这么做就是对的
- #include <cstdio>
- #include <iostream>
- #include <cstring>
- #include <algorithm>
- using namespace std;
- int n;
- bool ask(int n,int m,int x,int y){
- cout<<"? "<<n<<" "<<m<<" "<<x<<" "<<y<<endl;
- string s;
- cin>>s;
- return s[]=='Y';
- }
- int main(){
- string ans1="";
- string ans2="";
- scanf("%d",&n);
- int i=,j=;
- int cnt =;
- while (i<=n&&j<=n&&++cnt<=(n-)){
- if(ask(i,j+,n,n)){
- j++;
- ans1+="R";
- } else{
- i++;
- ans1+="D";
- }
- }
- i=n;j=n;cnt=;
- while (i>=&&j>=&&++cnt<=n-){
- if(ask(,,i-,j)){
- i--;
- ans2+="D";
- } else{
- j--;
- ans2+="R";
- }
- }
- reverse(ans2.begin(),ans2.end());
- printf("! ");
- cout<<ans1<<ans2;
- }
讲道理这套题要是放到我状态很好的时候我真有可能5题。。。当然很好这种东西一般不存在。。
我昨晚就出了BC两道题。。。惊了。。。
有个可怜的计科老兄被查重误判skip了。。。我也是第一次听说这种操作。。。
两题竟然还是蓝名,惊了。。。
今中午要好好睡午觉!!!md4点睡的八点多就起来来实验室补题结果没开门。。。(笔记本被我折磨了5个多小时gg了,,没带电源回去)
今晚edu可别再掉了,,,根据我的经验我现在已经达到极小点要开始反弹上紫了(雾
扩了一波学长的好友现在有将近十个好友注册了很开森QwQ
Codeforces Round 504的更多相关文章
- Codeforces Round #504 E. Down or Right
Codeforces Round #504 E. Down or Right 题目描述:交互题. 有一个\(n \times n\)的方阵,有一些格子是障碍,从\((1, 1)\)出发,只能向右向下走 ...
- Codeforces Round #504 D. Array Restoration
Codeforces Round #504 D. Array Restoration 题目描述:有一个长度为\(n\)的序列\(a\),有\(q\)次操作,第\(i\)次选择一个区间,将区间里的数全部 ...
- Codeforces 1023 A.Single Wildcard Pattern Matching-匹配字符 (Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Fi)
Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) A. Single Wildcard Patter ...
- E - Down or Right Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
http://codeforces.com/contest/1023/problem/E 交互题 #include <cstdio> #include <cstdlib> #i ...
- Codeforces Round #504:D. Array Restoration
D. Array Restoration 题目链接:https://codeforces.com/contest/1023/problem/D 题意: 给出一个序列,现在要求对一个全为0的序列执行q次 ...
- Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-D- Array Restoration
我们知道不满足的肯定是两边大中间小的,这样就用RMQ查询两个相同等值的区间内部最小值即可,注意边界条件 #include<bits/stdc++.h> #define x first #d ...
- Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-C-Bracket Subsequence
#include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> ...
- Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-A-Single Wildcard Pattern Matching
#include<iostream> #include<algorithm> #include<stdio.h> #include<string.h> ...
- Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) E. Down or Right
从(1,1,n,n)每次只变一个坐标,进行询问. 如果问到对角线有距离限制, 再从(1,1,n/2,n/2)询问到(n/2,n/2,n,n) 记住前半部分贪心忘上走,后本部分贪心往右走 因为最后的路线 ...
随机推荐
- C# Xamarin For Android自动升级项目实战
一.课程介绍 “明人不说暗话,跟着阿笨一起玩Xamarin”,本次分享课程阿笨将带来大家一起学习Xamarin For Android系列<C# Xamarin For Android自动升级项 ...
- 推荐一个好工具:P/Invoke Interop Assistant【转】
原文地址 :http://write.blog.csdn.net/postedit 在从托管代码里面调用非托管代码的时候,经常会翻阅MSDN找到需要调用的这个程序集里面的关于需要调用方法的签名,还要特 ...
- OSI(Open System Interconnect) 网络七层协议
你作为用户想发个快递,你叫来了顺丰,顺丰快递员从你手里拿走了快递,又装进一个盒子,然后把一个快递单子贴在了上面. 快递员回到集散中心,将快递往那一扔不管了,分拣员把快递按投递的省市分开,发往同一地区的 ...
- Linux安装NET CORE
Linux安装.NET CORE 1.Add the dotnet apt-get feed 为了在Ubuntu或Linux Mint上安装.NET,您需要首先设置托管所需软件包的apt-get fe ...
- Swift Struct 结构体
前言 Swift 语言有两种基本的数据类型,即类(class)和结构体(struct),class 这样的概念大家不会陌生,而 struct 也并不是什么新的概念,在 Objective-C 和 C ...
- 使用idea对spring boot项目打jar和war包[文件]
pom.xml文件编写 打JAR包时 <groupId>com.netcorner</groupId> <artifactId>demo</artifactI ...
- fastcgi php-cgi与php-fpm区别和之间的关系
关于FastCGI.php-cgi.php-fpm的区别是什么,各自有什么用途,以及相互间的关系是什么,查阅相关资料,可谓是众说纷纭,莫衷一是: 说法一:fastcgi是一个协议,php-fpm实现了 ...
- nginx:not a directory
项目需要在nginx中提供一个配置文件返回接口的信息,于是就添加了location来实现,本以为很简单的操作,结果访问配置文件时一直返回404,nginx的error log中输出:not a dir ...
- LaTeX数学模式&上下标&代码块
效果就是如上图所示了.学习了使用数学模式插入公式和使用上标和公式的编号.这里的目录没有展开,在编译一次目录会展开,代码块会被挤到下一页上面去. \documentclass[UTF8]{ctexart ...
- Android Studio编译报错“java.lang.OutOfMemoryError: GC overhead limit exceeded
1.在build.gradle添加脚本指定编译堆内存 如果在整个工程中生效,则在build.gradle中增加如下配置: android { .............. dexOptions { i ...