QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#323099#5660. Simplified Genome TranslationRabeya#Compile Error//C++205.1kb2024-02-08 14:47:562024-02-08 14:47:56

Judging History

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

  • [2024-02-08 14:47:56]
  • 评测
  • [2024-02-08 14:47:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef unordered_map<int,int> umap;
typedef long double ld;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define popcount __builtin_popcount
#define case cout<<"Case "<<__testcase-testcase<<": ";
#define endl '\n'
#define inf 1e18

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int testcase=1;
    //cin>>testcase;
    int __testcase=testcase;
    while(testcase--)
    {
        int n,m,k,q;
        cin>>n>>k>>m>>q;
        ll c[n+1];
        c[0]=0;
        for(int i=1;i<=n;i++) cin>>c[i];
        ll x[m+1];
        x[0]=0;
        for(int i=0;i<=m;i++) cin>>x[i];

        ll cumC[n+1]={0},cumX[m+1]={0};
        cumX[0]=x[0];

        for(int i=1;i<=n;i++) cumC[i]+=cumC[i-1]+c[i];
        for(int i=1;i<=m;i++) cumX[i]+=cumX[i-1]+x[i];

        set<int>s;
        while(q--)
        {
            char ch;
            cin>>ch;
            if(ch=='q'){
                int u,v;
                cin>>u>>v;
                if(u>v) swap(u,v);
                ll ans=inf;
                if(max(u,v)<=n){
                    //ll ans=inf;
                    //forward
                    auto it=s.lower_bound(u);
                    if(it!=s.end() and *it<=v-1);
                    else ans=cumC[v-1]-cumC[u-1];
                    //cout<<"ans1 "<<ans<<endl;

                    //backward
                    it=s.lower_bound(v);
                    if(it==s.end() or (s.size() ==0 or *s.begin()>=u)) ans=min(ans,cumC[n]-cumC[v-1]+cumC[u-1]);
                    //cout<<"ans2 "<<ans<<endl;

                    //zigzag
                    it=s.lower_bound(n+1);
                    if(it==s.end()) {
                        ll pth=cumX[m];
                        if
                        ans=min(ans,pth+cumC[max(u,k)-1]-cumC[min(u,k)-1]+cumC[n]-cumC[v-1]);
                        //cout<<"ans3 "<<ans<<endl;
                        ans=min(ans,pth+cumC[u-1]+cumC[v-1]-cumC[k-1]);
                        //cout<<"ans4 "<<ans<<endl;
                    }
                }
                else if(min(u,v)>n){
                   // ll ans=inf;
                    u-=n;
                    v-=n;
                    ans=min(ans,cumX[v-1]-cumX[u-1]);
                    ll pth=cumX[m]-(cumX[v-1]-cumX[u-1]);
                    auto it=s.lower_bound(k);
                    if(s.size()==0 or *s.begin()>=k) ans=min(ans,pth+cumC[k-1]);
                    if(it==s.end() ) ans=min(ans,pth+cumC[n]-cumC[k-1]);
                }
                else{
                    if(u>=k){
                        ll w=inf,x=inf,y=inf,z=inf,zz=inf;
                        if(s.size()==0 or *s.begin()>=k) w=cumC[k-1];
                        auto it=s.lower_bound(k);
                        if(it==s.end() or *it>=u) x=cumC[u-1]-cumC[k-1];

                        it=s.lower_bound(u);
                        if(it==s.end()) y=cumC[n]-cumC[u-1];

                        it=s.lower_bound(n+1);
                        if(it==s.end()) z=cumX[v-n-1];

                        it=s.lower_bound(v+1);
                        if(it==s.end()) zz=cumX[m]-cumX[v-n-1];

                        ans=min(ans,y+z);
                        ans=min(ans,y+w+zz);
                        ans=min(ans,x+zz);
                        ans=min(ans,x+w+z);



                    }
                    else{
                        ll w=inf,x=inf,y=inf,z=inf,zz=inf;
                        if(s.size()==0 or *s.begin()>=u) w=cumC[u-1];
                        auto it=s.lower_bound(u);
                        if(it==s.end() or *it>=k) x=cumC[k-1]-cumC[u-1];

                        it=s.lower_bound(k);
                        if(it==s.end()) y=cumC[n]-cumC[k-1];

                        it=s.lower_bound(n+1);
                        if(it==s.end()) z=cumX[v-n-1];

                        it=s.lower_bound(v+1);
                        if(it==s.end()) zz=cumX[m]-cumX[v-n-1];

                        ans=min(ans,w+z);
                        ans=min(ans,y+w+zz);
                        ans=min(ans,x+zz);
                        ans=min(ans,x+y+z);

                    }

                }
                if(ans<inf) cout<<ans<<endl;
                else cout<<"impossible"<<endl;
            }
            else if(ch=='c'){
                    int un;
                    cin>>un;
                    auto it=s.lower_bound(un);
                    if(it==s.end() or *it!=un) s.insert(un);
                    else s.erase(*it);

            }
            else{
                 int un;
                    cin>>un;
                    auto it=s.lower_bound(un+n+1);
                    if(it==s.end() or *it!=un) s.insert(un+n+1);
                    else s.erase(*it);
            }
        }
    }
}


/*
4 3 1 1
2 3 8 4
1 1
q 3 4
*/


Details

answer.code: In function ‘int main()’:
answer.code:73:25: error: expected ‘(’ before ‘ans’
   73 |                         ans=min(ans,pth+cumC[max(u,k)-1]-cumC[min(u,k)-1]+cumC[n]-cumC[v-1]);
      |                         ^~~
      |                         (