Codeforces Round #516 (Div. 1, by Moscow Team Olympiad) C

题链

Description

和交互库交互,你给出n个点,交互库指定颜色,求一条直线分割颜色。

Sol

分别在x轴,y轴上二分即可。

Code

#include<bits/stdc++.h>
#define Mid (l+r>>1)
using namespace std;
int n,l,r;
char p1[102],p2[102],p3[102];
void work(int x,int pos,int g) {
    l=500000000;
    r=1000000000;
    for (int i=x;i<n;i++) {
        printf("%d %d\n",pos,Mid); fflush(stdout);
        scanf("%s",p3+1);
        if (p2[1]==p3[1]) l=Mid; else r=Mid;
    }
    if (p1[1]==p2[1]) {
        if (p2[1]==p3[1])
           printf("%d %d %d %d\n",pos,Mid+1,pos+1,500000000);
        else printf("%d %d %d %d\n",pos,Mid-1,pos+1,500000000);
    } else {
        if (p2[1]==p3[1])
          printf("%d %d %d %d\n",pos,Mid+1,pos-1,500000000);
        else printf("%d %d %d %d\n",pos,Mid-1,pos-1,500000000);
    }

//    if (p2[1]==p1[1]) {
//        printf("%d %d %d %d\n",pos-(!g),Mid+1,pos-(!g)+1,1000000000-Mid-1);
//    } else {
//        printf("%d %d %d %d\n",pos-(!g),Mid-1,pos-(!g)+1,1000000000-Mid+1);
//    }
    exit(0);
}
signed main () {
    scanf("%d",&n);
    printf("0 500000000\n");fflush(stdout);
    scanf("%s",p1+1);
    l=0;
    r=1000000000;
    for (int i=1;i<n;i++) {
        if (Mid-l>=5&&r-Mid>=5)  { printf("%d %d\n",Mid,500000000); fflush(stdout); } else work(i,Mid,p1[1]==p2[1]);
        scanf("%s",p2+1);
        if (p2[1]==p1[1]) l=Mid; else r=Mid;
    }
    if (p2[1]==p1[1])  printf("%d 40000000 %d 600000000",Mid,Mid+1);
    else  printf("%d 40000000 %d 600000000",Mid-1,Mid);
    fflush(stdout);
}

原文地址:https://www.cnblogs.com/rrsb/p/9807240.html

时间: 2024-10-31 20:42:36

Codeforces Round #516 (Div. 1, by Moscow Team Olympiad) C的相关文章

Codeforces Round #516 (Div. 2, by Moscow Team Olympiad)

Codeforces Round #516 (Div. 2, by Moscow Team Olympiad) https://codeforces.com/contest/1064 A 1 #include<bits/stdc++.h> 2 #define pb push_back 3 using namespace std; 4 5 bool Check(int a,int b,int c){ 6 if(a+b>c&&b+c>a&&a+c>

Codeforces Round #516 (Div. 2, by Moscow Team Olympiad) D. Labyrinth

http://codeforces.com/contest/1064/problem/D 向上/向下加0,向左/右加1, step = 0,1,-- 求的是最少的步数,所以使用bfs. step=k -> step=k+1 1.step=k 使用一次左/右 到达 step=k+1 2.step=k+1 无限使用上下,得到所有 step=k+1 的状态 用dijkstra+堆优化 / spfa 超时. 1 #include <bits/stdc++.h> 2 using namespace

Codeforces Round #516 (Div. 1, by Moscow Team Olympiad) B

题链 Description 给一张方格图,对于上下移动无限制,左右移动数分别不能超过L,R,求能到多少点. Sol 发现 新的y坐标=老坐标-左移操作数+右移操作数 所以我们只需最小化左移操作数即可,最短路. Code #include<bits/stdc++.h> #define N 2007 #define pii pair<int,int> #define fi first #define se second using namespace std; char p[N][N

Codeforces Round #516 (Div. 1, by Moscow Team Olympiad) D

题链 Description 解一个线性规划(大雾) Sol 单纯形我们发现我们可以暴力枚举转的圈数,而这个东西可以数论分块优化. Code #include <bits/stdc++.h> #define LL long long using namespace std; LL n,x,k,lb,ub,l,r,ans=-1; int main() { scanf("%lld%lld%lld%lld",&n,&l,&r,&k); x=(r&g

Codeforces Round #516 (Div. 1, by Moscow Team Olympiad) E

题链 Description 给一个排列,要求每个激光打到指定的接受器上,最大化这个数量,你的手段只有在n*n的位置上放平面镜. Sol 我们发现一行要么只放‘/’要么只放‘\’,又发现answer=n||answer=n-1,这可以倒着合并. Description #include<bits/stdc++.h> #define N 1006 using namespace std; int n,a[N],last; char ans[N][N]; signed main () { scan

Codeforces Round #516 (Div. 2, by Moscow Team Olympiad) B

1 #include<bits/stdc++.h> 2 3 int n,T,cnt; 4 5 int read() 6 { 7 char ch = getchar(); 8 int num = 0; 9 bool fl = 0; 10 for (; !isdigit(ch); ch=getchar()) 11 if (ch=='-') fl = 1; 12 for (; isdigit(ch); ch=getchar()) 13 num = (num<<1)+(num<<

Codeforces Round #486 (Div. 3) A. Diverse Team

Codeforces Round #486 (Div. 3) A. Diverse Team 题目连接: http://codeforces.com/contest/988/problem/A Description There are n students in a school class, the rating of the i-th student on Codehorses is ai. You have to form a team consisting of k students

Codeforces Round #379 (Div. 2) Analyses By Team:Red &amp; Black

A.Anton and Danik Problems: 给你长度为N的,只含'A','D'的序列,统计并输出何者出现的较多,相同为"Friendship" Analysis: lucky_ji: 水题,模拟统计A和D的数目比较大小输出结果即可 Tags: Implementation B.Anton and Digits Problems: 给定k2个2,k3个3,k5个5及k6个6,可以组成若干个32或256,求所有方案中Sigma的最大值 Analysis: lucky_ji: 同

Codeforces Round #544 (Div. 3) C. Balanced Team [暴力剪枝]

You are a coach at your local university. There are n n students under your supervision, the programming skill of the i i -th student is a i ai . You have to create a team for a new programming competition. As you know, the more students some team ha