Codeforces Round 614 div2 解题报告

2019.1.20 星期一
各位新年好啊,作为一名留学生,每年不能回家真的太苦逼了,过年那几天对于18岁之前的我们来说是轻松和喜悦的代名词,18岁之后则成为了不能提及的伤心之处,不过日子还得继续。最近在纠结暑假是去实习还是留校做研究,实习的话,饿,一个手比脑子转的快的非应届生真的不好找,研究的话,一个是我校计算机并不那么强势,我不知道留在这里究竟能给我的简历增加多少分,另一个是我担心预支假期会把我的学习/比赛热情消耗殆尽,毕竟去年还是遇到了一些包括情感在内的重大问题,如果没有一个暑假的调节,和那次巧合,我真不知道去年后半学期该怎么度过,还好老天还是眷顾我的,才有后面的故事。算下来,我已经快20了,离出栏毕业成人 也没几天了,能够无忧无虑干自己想干的事情不知道还能有多久,不想把有限的青春浪费在这个小地方上。还有个选项,是中科院的暑期研究,也是一个合理的选项,不过现在来说一切还是个未知数,但我想把后学生时代过得精彩一些,那么多热闹没赶上,好不容易赶上一回,不想这么草草结束。

codeforces, 这次感觉A,B,C题不是很难(别说了,自己都睡过了), A题模板bfs(然而我居然忘了dfs不能回溯然后wa了一发),B题证明了一个道理,撑死胆大的,饿死胆小的,不过类似的结论以前高中微积分课堂上孙老师带我们一起证过,所以没能蒙到我,不过一个朋友就比我惨多了(不是无中生友!!),卡了半天没敢交,最后一发过了,不过耽误了好久, C题被群友带跑偏了,出题人描述不清晰,按照C题一定是思维含量低的模拟题的角度出发,他题目描述写的是farthest can reach我理解成需要考虑时间和空间的同步性,一个群友跟我说路径会变化,我也没多想模拟了半天,结果一直wa,后来才发现原来操作的时候一直是原地不动,好吧,思维不规范,rating两行泪,ac代码如下

#include <bits/stdc++.h>
using namespace std;
#define limit 1000000 + 5//防止溢出
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f3ff
#define lowbit(i) i&(-i)//一步两步
#define EPS 1e-6
#define Modulo 1000000
#define ff(a) printf("%d\n",a );
#define MOD 1000000000 + 7
#define midd l + (r - l ) / 2
#define mint(a,b,c) min(min(a,b), c)
#define FOPEN freopen("C:\\Users\\administrator01\\CLionProjects\\untitled19\\data.txt", "rt", stdin)
typedef long long ll;
void read(int &x){
    char ch = getchar();x = 0;
    for (; ch < '0' || ch > '9'; ch = getchar());
    for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}//快读
int read(){
    int x;
    char ch = getchar();x = 0;
    for (; ch < '0' || ch > '9'; ch = getchar());
    for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    return x;
}//快读
int vis[limit];
int n ,s, k;
ll dfs(ll start, map<ll,int>c, map<ll, int>vis){
    queue<int>q;
    q.push(start);
    ll ans;
    while(q.size()){
        int at = q.front();
        q.pop();
        vis[at] = 1;
        if(!c[at]){
            ans = at;
            break;
        }
        if(at - 1 >= 1 && !vis[at - 1]){
            q.push(at - 1);
        }
        if(at + 1 <= n && !vis[at + 1]){
            q.push(at + 1);
        }
    }
    return abs(ans - start);
}
int main(){
#ifdef LOCAL
    FOPEN;
#endif
    int kase;
    kase = read();
    while(kase--){
        scanf("%d%d%d" , &n, &s, &k);
        map<ll, int>close,vis;
 
        for(int i = 1 ; i <= k ; ++i){
            ll pos;
            scanf("%lld", &pos);
            close[pos] = 1;
        }
        cout<<dfs(s,close,vis)<<endl;
    }
    return 0;
}

B题

#include <bits/stdc++.h>
using namespace std;
#define limit 1000000 + 5//防止溢出
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f3ff
#define lowbit(i) i&(-i)//一步两步
#define EPS 1e-6
#define Modulo 1000000
#define ff(a) printf("%d\n",a );
#define MOD 1000000000 + 7
#define midd l + (r - l ) / 2
#define mint(a,b,c) min(min(a,b), c)
#define FOPEN freopen("C:\\Users\\administrator01\\CLionProjects\\untitled19\\data.txt", "rt", stdin)
typedef long long ll;
void read(int &x){
    char ch = getchar();x = 0;
    for (; ch < '0' || ch > '9'; ch = getchar());
    for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}//快读
int read(){
    int x;
    char ch = getchar();x = 0;
    for (; ch < '0' || ch > '9'; ch = getchar());
    for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    return x;
}//快读
int n;
int main(){
#ifdef LOCAL
    FOPEN;
#endif
    n = read();
    double ans;
    ans = 0;
    for(int i = 1 ; i <= n ; ++i){
        ans += 1.00000/ i;
    }
    printf("%.4lf" , ans);
    return 0;
}

C题

#include <bits/stdc++.h>
using namespace std;
#define limit 1000000 + 5//防止溢出
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f3ff
#define lowbit(i) i&(-i)//一步两步
#define EPS 1e-6
#define Modulo 1000000
#define ff(a) printf("%d\n",a );
#define MOD 1000000000 + 7
#define midd l + (r - l ) / 2
#define mint(a,b,c) min(min(a,b), c)
#define FOPEN freopen("C:\\Users\\administrator01\\CLionProjects\\untitled19\\data.txt", "rt", stdin)
typedef long long ll;
void read(int &x){
    char ch = getchar();x = 0;
    for (; ch < '0' || ch > '9'; ch = getchar());
    for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}//快读
int read(){
    int x;
    char ch = getchar();x = 0;
    for (; ch < '0' || ch > '9'; ch = getchar());
    for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    return x;
}//快读
int n, m;
map<int , int>v[2];
int judge(int x,int y){
    int ans = 0;
    if(v[x][y]) {
        if (v[x ^ 1][y])++ans;
        if (v[x ^ 1][y - 1])++ans;
        if (v[x ^ 1][y + 1])++ans;
    }else{
        if (v[x ^ 1][y])--ans;
        if (v[x ^ 1][y - 1])--ans;
        if (v[x ^ 1][y + 1])--ans;
    }
    return ans;
}
int main(){
#ifdef LOCAL
    FOPEN;
#endif
    cin>>n>>m;
    int cnt = 0;
    for(int i = 1; i <= m ; ++i){
        int x, y;
        cin>>x>>y;
        x--;
        int flagh = v[x][y];
        v[x][y] = !flagh;
        cnt += judge(x,y);
        puts(!cnt ? "YES" : "NO");
    }
    return 0;
}

D题dfs写爆栈了,还在想呢。

发布了69 篇原创文章 · 获赞 0 · 访问量 2851

猜你喜欢

转载自blog.csdn.net/Stagflation/article/details/104058182