Codeforces Round 930 (Div. 2) C. Bitwise Operation Wizard

题目

思路:

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define lson p << 1
#define rson p << 1 | 1
const int maxn = 1e6 + 5, inf = 1e9, maxm = 4e4 + 5;
const int N = 1e6;
 const int mod = 1e9 + 7;
// const int mod = 998244353;
//const __int128 mod = 212370440130137957LL;
// int a[505][5005];
// bool vis[505][505];
// char s[3][maxn];
int a[maxn], b[maxn];
bool vis[maxn];
// string s;
int n, m;

struct Node{
    int val, id;
    bool operator<(const Node &u)const{
        return val < u.val;
    }
};
// Node c[maxn];

int ans[maxn];
int pre[maxn];

char ask(int a, int b, int c, int d){
    char ch;
    cout << "? " << a << ' ' << b << ' ' << c << ' ' << d << '\n';
    cout.flush();
    cin >> ch;
    return ch;
}
//long long ? maxn ?
void solve(){
    int res = 0;
    int q, k;
    cin >> n;
	// for(int i = 1; i <= n; i++){
	// 	cin >> a[i];
	// }
    int id_min = 0, id_max = 0;
    char ch;
    for(int i = 1; i < n; i++){
        ch = ask(i, i, id_max, id_max);
        if(ch == '>'){
            id_max = i;
        }
    }
    int id = 0;
    vector<int> vec;
    for(int i = 0; i < n; i++){
        ch = ask(id_max, i, id_max, id);
        if(ch == '>'){
            vec.clear();
            vec.pb(i);
            id = i;
        }
        else if(ch == '='){
            vec.pb(i);
        }
    }
    id = vec[0];
    for(int i = 1; i < vec.size(); i++){
        int x = vec[i];
        ch = ask(x, x, id, id);
        if(ch == '<'){
            id = x;
        }
    }
    cout << "! " << id << ' ' << id_max << '\n';
    cout.flush();
}
    
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int T = 1;
   cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}

相关推荐

  1. Codeforces Round 936 (Div. 2)

    2024-04-02 02:32:01       31 阅读
  2. codeforce#939 (div2) 题解

    2024-04-02 02:32:01       145 阅读
  3. Codeforces Round 936 (Div. 2) (A~C)

    2024-04-02 02:32:01       42 阅读
  4. Codeforces Round 934 (Div. 2) D

    2024-04-02 02:32:01       36 阅读
  5. Codeforces Round 960 (Div. 2)VP

    2024-04-02 02:32:01       25 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-02 02:32:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-02 02:32:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-02 02:32:01       82 阅读
  4. Python语言-面向对象

    2024-04-02 02:32:01       91 阅读

热门阅读

  1. MySQL 入门教程

    2024-04-02 02:32:01       35 阅读
  2. C#WPF控件大全

    2024-04-02 02:32:01       32 阅读
  3. 7.公约移动

    2024-04-02 02:32:01       37 阅读
  4. (less) calc运算为什么不生效? 变量如何使用?

    2024-04-02 02:32:01       33 阅读
  5. 纯css 实现div 或者 图片一大一小的过渡动画

    2024-04-02 02:32:01       36 阅读
  6. LeetCode //C - 436. Find Right Interval

    2024-04-02 02:32:01       34 阅读
  7. Windows下配深度学习环境

    2024-04-02 02:32:01       38 阅读
  8. docker入门

    2024-04-02 02:32:01       32 阅读
  9. python中线程与协程

    2024-04-02 02:32:01       35 阅读
  10. 微信小程序中实现埋点的方法

    2024-04-02 02:32:01       41 阅读
  11. Azure入门实践-如何创建两个虚拟网络的对等连接

    2024-04-02 02:32:01       38 阅读
  12. C++ 学习10大网站推荐(Bjarne Stroustrup)

    2024-04-02 02:32:01       33 阅读
  13. 二分查找算法刷题记录 -LC34

    2024-04-02 02:32:01       36 阅读
  14. Linux 服务service(一)

    2024-04-02 02:32:01       32 阅读