QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#524217#5669. Traveling in Jade Cityucup-team3699#Compile Error//C++204.9kb2024-08-19 12:54:142024-08-19 12:54:14

Judging History

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

  • [2024-08-19 12:54:14]
  • 评测
  • [2024-08-19 12:54:14]
  • 提交

answer

//#include<bits/stdc++.h>

using namespace std;

#define int long long
#define pb push_back
#define F first 
#define S second 

const int mol=998244353;
const int N = 1e6+5;

int c[N], x[N];
set<int>n1, n2;
int pre1[1000005], pre2[1000005];
int n, k, m, q;

bool no(int t1, int t2){
    if(t2==-1){
        if(*n1.lower_bound(t1)>=n+1) return 1;
        return 0;
    }
    if(t1>t2) swap(t1, t2);
    if(t2<=n){
        if(*n1.lower_bound(t1)>=t2) return 1;
        return 0;
    }
    else{
        if(t1==1) t1=0;
        else t1-=n;
        t2-=n;
        if(*n2.lower_bound(t1)>=t2) return 1;
        return 0;
    }
}

void solve(){
    cin>>n>>k>>m>>q;
    for(int i=1;i<=n;i++) cin>>c[i], pre1[i]=pre1[i-1]+c[i];
    for(int i=0;i<=m;i++) {
        cin>>x[i];
        if(i==0) pre2[i]=x[i];
        else pre2[i]=pre2[i-1]+x[i];    
    }
    n1.insert(1e18), n2.insert(1e18);
    while(q--){
        char t;
        cin>>t;
        if(t=='q'){
            int g, h;
            cin>>g>>h;
            if(g==h){
                cout<<"0\n";
                continue;
            }
            
            if(g>h) swap(g, h);
            
            int ans=1e18;
            if(h<=k){
                if(*n1.lower_bound(g)>=h) ans=pre1[h-1]-pre1[g-1];
                if(no(1, g)&&no(1, n+m+1)&&no(h, k)) ans=min(ans, pre1[g-1]+pre2[m]+pre1[k-1]-pre1[h-1]);
                if(no(1, g)&&no(h, -1)) ans=min(ans, pre1[n]-pre1[h-1]+pre1[g-1]);
            }
            else if(h<=n){
                if(g<k){
                    if(no(g, h)) ans=pre1[h-1]-pre1[g-1];
                    if(no(1, g)&&no(h, -1)) ans=min(ans, pre1[g-1]+pre1[n]-pre1[h-1]);
                    if(n2.size()==0){
                        if(no(g, k)&&no(h, -1)) ans=min(ans, pre2[m]+pre1[k-1]-pre1[g-1]+pre1[n]-pre1[h-1]);
                        if(no(1, g)&&no(k, h)) ans=min(ans, pre2[m]+pre1[g-1]+pre1[h-1]-pre1[k-1]);
                    }
                }
                else{
                    if(no(g, h)) ans=pre1[h-1]-pre1[g-1];
                    if(no(h, -1)&&no(k, g)&&no(1, n+m+1)) ans=min(ans, pre1[g-1]-pre1[k-1]+pre2[m]+pre1[n]-pre1[h-1]);
                    if(no(1, g)&&no(h, -1)) ans=min(ans, pre1[n]-pre1[h-1]+pre1[g-1]);
                }
            }
            else{
                if(g==1){
                    if(no(1, h)) ans=min(ans, pre2[h-n-1]);
                    if(no(1, k)&&no(h, n+m+1)) ans=min(ans, pre1[k-1]+pre2[m]-pre2[h-n-1]);
                    if(no(k, -1)&&no(h, n+m+1)) ans=min(ans, pre1[n]-pre1[k-1]+pre2[m]-pre2[h-n-1]);
                }
                else if(g==k){
                    if(no(h, n+m+1)) ans=min(ans, pre2[m]-pre2[h-n-1]);
                    if(no(1, k)&&no(1, h)) ans=min(ans, pre1[k-1]+pre2[h-n-1]);
                    if(no(k, -1)&&no(1, h)) ans=min(ans, pre1[n]-pre1[k-1]+pre2[h-n-1]);
                }
                else if(g>=n+1){
                    if(no(g, h)) ans=pre2[h-n-1]-pre2[g-n-1];
                    if(no(1, g)&&no(h, n+m+1)){
                        if(no(k, -1)) ans=min(ans, pre2[g-n-1]+pre2[m]-pre2[h-n-1]+pre1[n]-pre1[k-1]);
                        if(no(1, k)) ans=min(ans, pre2[g-n-1]+pre2[m]-pre2[h-n-1]+pre1[k-1]);
                    }
                }
                else{
                    if(g<=k-1){
                        if(no(h, n+m+1)){
                            if(no(g, k)) ans=min(ans, pre1[k-1]-pre1[g-1]+pre2[m]-pre2[h-n-1]);
                            if(no(1, g)&&no(k, -1)) ans=min(ans, pre1[g-1]+pre1[n]-pre1[k-1]+pre2[m]-pre2[h-n-1]);
                        }
                        if(no(1, h)){
                            if(no(1, g)) ans=min(ans, pre1[g-1]+pre2[h-n-1]);
                            if(no(g, -1)) ans=min(ans, pre1[n]-pre1[g-1]+pre2[h-n-1]);
                        }
                    }
                    else{
                        if(no(h, n+m+1)){
                            if(no(k, g)) ans=min(ans, pre1[g-1]-pre1[k-1]+pre2[m]-pre2[h-n-1]);
                            if(no(g, -1)&&no(1, k)) ans=min(ans, pre1[k-1]+pre1[n]-pre1[g-1]+pre2[m]-pre2[h-n-1]);
                        }
                        if(no(1, h)){
                            if(no(1, g)) ans=min(ans, pre1[g-1]+pre2[h-n-1]);
                            if(no(g, -1)) ans=min(ans, pre1[n]-pre1[g-1]+pre2[h-n-1]);
                        }
                    }
                }

            }
            if(ans==1e18) cout<<"impossible\n";
            else cout<<ans<<"\n";
        }
        if(t=='c'){
            int g;
            cin>>g;
            if(n1.count(g)) n1.erase(g);
            else n1.insert(g);
        }
        if(t=='x'){
            int g;
            cin>>g;
            if(n2.count(g)) n2.erase(g);
            else n2.insert(g);   
        }
    }
}

signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
    solve();
    return 0;
}

詳細信息

answer.code:14:1: error: ‘set’ does not name a type
   14 | set<int>n1, n2;
      | ^~~
answer.code: In function ‘bool no(long long int, long long int)’:
answer.code:20:13: error: ‘n1’ was not declared in this scope; did you mean ‘t1’?
   20 |         if(*n1.lower_bound(t1)>=n+1) return 1;
      |             ^~
      |             t1
answer.code:23:15: error: ‘swap’ was not declared in this scope
   23 |     if(t1>t2) swap(t1, t2);
      |               ^~~~
answer.code:25:13: error: ‘n1’ was not declared in this scope; did you mean ‘t1’?
   25 |         if(*n1.lower_bound(t1)>=t2) return 1;
      |             ^~
      |             t1
answer.code:32:13: error: ‘n2’ was not declared in this scope; did you mean ‘t2’?
   32 |         if(*n2.lower_bound(t1)>=t2) return 1;
      |             ^~
      |             t2
answer.code: In function ‘void solve()’:
answer.code:38:5: error: ‘cin’ was not declared in this scope
   38 |     cin>>n>>k>>m>>q;
      |     ^~~
answer.code:1:1: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
  +++ |+#include <iostream>
    1 | //#include<bits/stdc++.h>
answer.code:45:5: error: ‘n1’ was not declared in this scope; did you mean ‘no’?
   45 |     n1.insert(1e18), n2.insert(1e18);
      |     ^~
      |     no
answer.code:45:22: error: ‘n2’ was not declared in this scope; did you mean ‘no’?
   45 |     n1.insert(1e18), n2.insert(1e18);
      |                      ^~
      |                      no
answer.code:53:17: error: ‘cout’ was not declared in this scope
   53 |                 cout<<"0\n";
      |                 ^~~~
answer.code:53:17: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
answer.code:57:21: error: ‘swap’ was not declared in this scope
   57 |             if(g>h) swap(g, h);
      |                     ^~~~
answer.code:62:58: error: ‘min’ was not declared in this scope
   62 |                 if(no(1, g)&&no(1, n+m+1)&&no(h, k)) ans=min(ans, pre1[g-1]+pre2[m]+pre1[k-1]-pre1[h-1]);
      |                                                          ^~~
answer.code:63:45: error: ‘min’ was not declared in this scope
   63 |                 if(no(1, g)&&no(h, -1)) ans=min(ans, pre1[n]-pre1[h-1]+pre1[g-1]);
      |                                             ^~~
answer.code:68:49: error: ‘min’ was not declared in this scope
   68 |                     if(no(1, g)&&no(h, -1)) ans=min(ans, pre1[g-1]+pre1[n]-pre1[h-1]);
      |                                                 ^~~
answer.code:70:53: error: ‘min’ was not declared in this scope
   70 |                         if(no(g, k)&&no(h, -1)) ans=min(ans, pre2[m]+pre1[k-1]-pre1[g-1]+pre1[n]-pre1[h-1]);
      |                                                     ^~~
answer.code:71:52: error: ‘min’ was not declared in this scope
   71 |                         if(no(1, g)&&no(k, h)) ans=min(ans, pre2[m]+pre1[g-1]+pre1[h-1]-pre1[k-1]);
      |                                                    ^~~
answer.code:76:63: error: ‘min’ was not declared in this scope
   76 |                     if(no(h, -1)&&no(k, g)&&no(1, n+m+1)) ans=min(ans, pre1[g-1]-pre1[k-1]+pre2[m]+pre1[n]-pre1[h-1]);
      |                                                               ^~~
answer.code:77:49: error: ‘min’ was not declared in this scope
   77 |                     if(no(1, g)&&no(h, -1)) ans=min(ans, pre1[n]-pre1[h-1]+pre1[g-1]);
      |                                                 ^~~
answer.code:82:38: error: ‘min’ was not declared in this scope
   82 |                     if(no(1, h)) ans=min(ans, pre2[h-n-1]);
      |                                      ^~~
answer.code:83:52: error: ‘min’ was not declared in this scope
   83 |                     if(no(1, k)&&no(h, n+m+1)) ans=min(ans, pre1[k-1]+pre2[m]-pre2[h-n-1]);
      |                                                    ^~~
answer.code:84:53: error: ‘min’ was not declared in this scope
   84 |                     if(no(k, -1)&&no(h, n+m+1)) ans=min(ans, pre1[n]-pre1[k-1]+pre2[m]-pre2[h-n-1]);
      |                                                     ^~~
answer.code:87:42: error: ‘min’ was not declared in this scope
   87 |                     if(no(h, n+m+1)) ans=min(ans, pre2[m]-pre2[h-n-1]);
      |                                          ^~~
answer.code:88:48: error: ‘min’ was not declared in this scope
   88 |                     if(no(1, k)&&no(1, h)) ans=min(ans, pre1[k-1]+pre2[h-n-1]);
      |                                                ^~~
answer.code:89:49: error: ‘min’ was not declared in this scope
   89 |                     if(no(k, -1)&&no(1, h)) ans=min(ans, pre1[n]-pre1[k-1]+pre2[h-n-1]);
      |                                                 ^~~
answer.code:94:43: error: ‘min’ was not declared in this scope
   94 |                         if(no(k, -1)) ans=min(ans, pre2[g-n-1]+pre2[m]-pre2[h-n-1]+pre1[n]-pre1[k-1]);
      |                                        ...