QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#560720#9239. Hieroglyphschenxinyang2006#Compile Error//C++203.7kb2024-09-12 17:31:122024-09-12 17:31:13

Judging History

This is the latest submission verdict.

  • [2024-09-12 17:31:13]
  • Judged
  • [2024-09-12 17:31:12]
  • Submitted

answer

#include "hieroglyphs.h"
#include <bits/stdc++.h>
#include "grader.cpp"
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
//#define mod 998244353
//#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;

template <class T>
void chkmax(T &x,T y){
  if(x < y) x = y;
}

template <class T>
void chkmin(T &x,T y){
  if(x > y) x = y;
}

inline int popcnt(int x){
  return __builtin_popcount(x);
}

inline int ctz(int x){
  return __builtin_ctz(x);
}
int n,m;
int a[3005],b[3005],prv[2][3005],sp[2][3005];
map <int,int> buc;
map <int,ull> qwq,awa;
ull val[2][3005];

/*#define lowbit(x) (x & (-x))
ull tree[3005];
void upd(int pos,ull C){
    pos++;
    while(pos <= m + 1){
        tree[pos] += C;
        pos += lowbit(pos);
    }
}

ull qry(int pos){
    pos++;
    ull ret = 0;
    while(pos){
        ret += tree[pos];
        pos -= lowbit(pos);
    }
    return ret;
}*/

ull sum[3005][3005],dp[3005][3005];
int f[3005][3005];

int sz;
int c[3005];
mt19937_64 rnd(0);
vector<int> ucs(vector<int> A,vector<int> B) {
    n = SZ(A);m = SZ(B);
    rep(i,1,n) a[i] = A[i - 1];
    rep(i,1,m) b[i] = B[i - 1];
    rep(i,1,n){
        if(buc[a[i]]){
            prv[0][i] = buc[a[i]] - 1;
        }else{
            sp[0][i] = 1;
            prv[0][i] = 0;
        }
        buc[a[i]] = i;
    }
    buc.clear();
    rep(i,1,m){
        if(buc[b[i]]){
            prv[1][i] = buc[b[i]] - 1;
        }else{
            sp[1][i] = 1;
            prv[1][i] = 0;
        }
        buc[b[i]] = i;
    }
    rep(i,1,n){
        if(qwq.find(a[i]) == qwq.end()) qwq[a[i]] = rnd();
        val[0][i] = qwq[a[i]];
    }
    rep(i,1,m){
        if(qwq.find(b[i]) == qwq.end()) qwq[b[i]] = rnd();
        val[1][i] = qwq[b[i]];
    }    
    ull ssum = 0;
    rep(i,1,n){
        rep(j,1,m){
            if(a[i] != b[j]) continue;
            if(sp[0][i] && sp[1][j]) dp[i][j]++;
            dp[i][j] += sum[i - 1][j - 1] - sum[prv[0][i]][j - 1] - sum[i - 1][prv[1][j]] + sum[prv[0][i]][prv[1][j]];
/*            rep(p,prv[0][i],i - 1){
                rep(q,prv[1][j],j - 1) if(i != p || j != q) dp[i][j] += dp[p][q];
            }*/
            dp[i][j] *= val[0][i];
            ssum += dp[i][j];
        }
        rep(j,1,m) sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + dp[i][j];
//        rep(j,1,m) printf("%llu ",dp[i][j]);
//        printf("\n");
    }
    rep(i,1,n){
        rep(j,1,m){
            f[i][j] = max(f[i - 1][j],f[i][j - 1]);
            if(a[i] == b[j]) chkmax(f[i][j],f[i - 1][j - 1] + 1);
        }
    }
    int p = n,q = m;
    while(p && q){
        if(a[p] == b[q] && f[p - 1][q - 1] + 1 == f[p][q]){
            c[++sz] = a[p];
            p--;
            q--;
            continue;
        }
        if(f[p - 1][q] == f[p][q]) p--;
        else if(f[p][q - 1] == f[p][q]) q--;
        else assert(0);
    }
    reverse(c + 1,c + sz + 1);
//    rep(i,1,sz) cerr << c[i] << " ";
//    cerr << endl;

    ull ovo = 0,tovo;
    rep(i,1,sz){
        tovo = (ovo - awa[c[i]] + 1) * qwq[c[i]];
        awa[c[i]] = ovo + 1;
//        printf("%llu ",awa[c[i]]);
        ovo += tovo;
    }
//    cerr << ovo << endl;
    vector <int> ans(1,-1);
    if(ovo != ssum) return ans;
    ans.clear();
    rep(i,1,sz) ans.eb(c[i]);
    return ans;
}
/*

*/

详细

answer.code:3:10: fatal error: grader.cpp: No such file or directory
    3 | #include "grader.cpp"
      |          ^~~~~~~~~~~~
compilation terminated.