跳到正文

个人记录

畅奥讲题代码

yuchanxianqwq约 2 分钟
原文
文章信息与版本

文章信息

收录
2026年7月11日
更新
2026年7月11日
篇幅
约 2 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
#define int long long
#define y1 qht_yjx
#define hash ZhaoAk
#define maxn 2000005
// #define endl "\n"
#define nullptr 0
#define I ios::sync_with_stdio (nullptr);
#define AK cin.tie (nullptr);
#define CSP cout.tie (nullptr);


using namespace std;


int n;


signed main()
{
	I AK CSP

    cin >> n;
    int l = 1 ,r = 1 ,ans = 0;
    
    for ( ; l <= n ;l ++)
    {
        if (r <= l)
            r = l + 1;
        while (r <= n)
        {
            cout << "? " << l << " " << r << endl;
            string s;
            cin >> s;
            if (s[0] == 'N')
            {
                ans += (r - l - 1);
                break ;
            }
            if (r < n)
                r ++;
            else
            {
                ans += (r - l);
                break ;
            }
        }
        
    }

    cout << "! " << ans << endl;

	return !!!!! ("ShZhao" && "SHzhao");
}
//Code by Lyyq.
//wage.

原文