QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#538073#5128. Dividing DNA qwqqwqqwqeCompile Error//C++172.8kb2024-08-30 22:52:122024-08-30 22:52:13

Judging History

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

  • [2024-08-30 22:52:13]
  • 评测
  • [2024-08-30 22:52:12]
  • 提交

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
*/#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
*/

Details

answer.code:74:11: error: redefinition of ‘const int maxn’
   74 | const int maxn = 1e4+5;
      |           ^~~~
answer.code:11:11: note: ‘const int maxn’ previously defined here
   11 | const int maxn = 1e4+5;
      |           ^~~~
answer.code:75:5: error: redefinition of ‘int a [10005]’
   75 | int a[maxn];
      |     ^
answer.code:12:5: note: ‘int a [10005]’ previously declared here
   12 | int a[maxn];
      |     ^
answer.code:76:5: error: redefinition of ‘int dp [10005]’
   76 | int dp[maxn];
      |     ^~
answer.code:13:5: note: ‘int dp [10005]’ previously declared here
   13 | int dp[maxn];
      |     ^~
answer.code:78:5: error: redefinition of ‘int query(int, int)’
   78 | int query (int l, int r) {
      |     ^~~~~
answer.code:15:5: note: ‘int query(int, int)’ previously defined here
   15 | int query (int l, int r) {
      |     ^~~~~
answer.code:84:8: error: redefinition of ‘int main()’
   84 | signed main () {
      |        ^~~~
answer.code:21:8: note: ‘int main()’ previously defined here
   21 | signed main () {
      |        ^~~~