QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#538074#5128. Dividing DNA qwqqwqqwqeWA 1ms3532kbC++171.4kb2024-08-30 22:52:342024-08-30 22:52:34

Judging History

你现在查看的是最新测评结果

  • [2024-08-30 22:52:34]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3532kb
  • [2024-08-30 22:52:34]
  • 提交

answer

#include"bits/stdc++.h"
#define _det(...) fprintf(stderr,__VA_ARGS__)
#define Print(a) cerr<<a<<"\n"
#define IOS ios::sync_with_stdio(0);cin.tie(0)
#define Cases int T;cin>>T;while(T--)
#define Debug(in) cerr<<#in<<" = "<<(in)<<"\n"
#define Watch(in) Detect;Debug(in);
#define Detect _det("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
using namespace std;

const int maxn = 1e4+5;
int a[maxn];
int dp[maxn];

int query (int l, int r) {
    cout<<"? "<<l-1<<" "<<r-1<<endl;
    string s;cin>>s;
    if (s == "present") return true;
    else return false;
}
signed main () {
    int n; cin>>n;
    int r = 1;
    int l = 1;
    while (r<=n) {
        int present = query(l,r);
        if (present) {
            a[r] = l-1;
            if (a[r] == 0) a[r] = -1;
        }
        else {
            while (l<r && !present) {
                l++;
                present = query(l,r);
            }
            if (l == r && !present) a[r] = r;
            else a[r] = l-1;
        }
        r++;
    }   
    // for (int i=1;i<=n;i++) {
    //     cerr<<a[i]<<" ";
    // }
    // cerr<<endl;
    for (int i=1;i<=n;i++) {
        if (a[i] == -1) continue;
        for (int j=0;j<a[i];j++) {
            dp[i] = max(dp[i],dp[j]+1);
        }
    }
    cout<<"! "<<dp[n]<<endl;
}
/*
5
present
absent
present
absent
present
present
absent
absent
present
*/

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3532kb

input:

1

output:

? 0 0

result:

wrong answer l must be non-empty