QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#617805#7757. Palm IslandSatonCompile Error//C++206.7kb2024-10-06 17:11:222024-10-06 17:11:22

Judging History

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

  • [2024-10-06 17:11:22]
  • 评测
  • [2024-10-06 17:11:22]
  • 提交

answer

///by Saton.
#include<bits/stdc++.h>
#define PI acos(-1)
#define fi first
#define se second 
#define sz(a) ((int)a.size())
#define all(a) a.begin(), a.end()
#define LL long long
#define ll __int128
#define DD double double
#define LD long double
#define rep(i,a,b) for(LL i = (a);i <= (b);i ++)
#define lep(i,a,b) for(LL i = (a);i >= (b);i --)
#define FLUSH fflush(stdout)
using namespace std;
const int N = 2e5 + 10,mod =  1e9+7,P = 131;
const LL inf = 1e9+10,INF = 1e18+10;
typedef pair<int,int> PII;
typedef pair<LL,int> PLI;
typedef pair<LL,LL> PLL;
//__builtin_popcountll()计算整数二进制表示中1的个数
// mt19937_64 rnd(random_device{}());
// uniform_int_distribution<LL> dist(0, LLONG_MAX);//dist(rnd)生成随机数
LL n,m,k;
string str;
int dx[4] = {-1,1,0,0},dy[4] = {0,0,-1,1};
// __int128//最大可用整数类型
// struct Node {
//     int l,r;
//     bool operator<(const Node &u) const {
//         return l < u.l;
//     }
// }node[N];
 
LL qmi(LL a,LL b,LL p) {LL res = 1;while(b) {if(b&1) res = (LL)res*a%p;a = (LL)a*a%p;b >>= 1;}return res%p;}
LL gcd(LL a,LL b) {return b ? gcd(b,a%b) : a;}
LL lcm(LL a,LL b) {return (LL)a*b / gcd(a,b);}
LL lowbit(LL x) {return x & -x;}
void print(ll x) {
    if(x<0) putchar('-'),x = -x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
// const int M = 3.2e3 + 10;
// int primses[M],cnt,val[N],res[N];
// bool st[M];
// void gar() {
//     for(int i = 2;i <= M;i ++) {
//         if(!st[i]) primses[cnt ++] = i;
//         for(int j = 0;primses[j]*i <= M;j ++) {
//             st[primses[j]*i] = true;
//             if(i%primses[j]==0) break;
//         }
//     }
// }
// const int M = 2e5+10;
// LL fact[M],infact[M];
// void cmb() {
//     fact[0] = infact[0] = 1;
//     for(int i = 1;i < M;i ++) fact[i] = fact[i-1]*i%mod;
//     infact[M-1] = qmi(fact[M-1],mod-2,mod)%mod;
//     for(int i = M-2;i >= 0;i --) infact[i] = infact[i+1]*(i+1)%mod;
// }
// LL C(int a,int b) {
//     if(a<b) return 0;
//     return (LL)fact[a]*infact[b]%mod*infact[a-b]%mod;
// }    

void solve() {
    int n;
    std::cin >> n;
 
    std::vector<int> a(n), b(n);
    for (int i = 0; i < n; i++)
        std::cin >> a[i], a[i]--;
    for (int i = 0; i < n; i++)
        std::cin >> b[i], b[i]--;
 
    std::vector<int> L(n);
    for (int i = 0; i < n; i++) {
        L[b[i]] = b[(i + n - 1) % n];
    }
 
    std::string res;
    for (int _ = 0; _ < n; _++) {
        int base = a[0];
 
        // 将L[a[0]]旋转到头
        auto pos = std::find(a.begin(), a.end(), L[base]);
        res.insert(res.end(), pos - a.begin(), '1');
        std::rotate(a.begin(), pos, a.end());
 
        // 将刚刚的a[0]旋转到1
        pos = std::find(a.begin(), a.end(), base);
        res.insert(res.end(), pos - a.begin() - 1, '2');
        std::rotate(a.begin() + 1, pos, a.end());
    }
 
    // 最后旋转到和答案一样
    auto pos = std::find(a.begin(), a.end(), b[0]);
    res.insert(res.end(), pos - a.begin(), '1');
    std::rotate(a.begin(), pos, a.end());
 
    std::cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T;
    cin >> T;
    while(T --) { 
        solve();
    }
    // solve();
       
    return 0;
}  
/*   /\_/\
*   (= ._.)
*   / >  \>
*////by Saton.
#include<bits/stdc++.h>
#define PI acos(-1)
#define fi first
#define se second 
#define sz(a) ((int)a.size())
#define all(a) a.begin(), a.end()
#define LL long long
#define ll __int128
#define DD double double
#define LD long double
#define rep(i,a,b) for(LL i = (a);i <= (b);i ++)
#define lep(i,a,b) for(LL i = (a);i >= (b);i --)
#define FLUSH fflush(stdout)
using namespace std;
const int N = 2e5 + 10,mod =  1e9+7,P = 131;
const LL inf = 1e9+10,INF = 1e18+10;
typedef pair<int,int> PII;
typedef pair<LL,int> PLI;
typedef pair<LL,LL> PLL;
//__builtin_popcountll()计算整数二进制表示中1的个数
// mt19937_64 rnd(random_device{}());
// uniform_int_distribution<LL> dist(0, LLONG_MAX);//dist(rnd)生成随机数
LL n,m,k;
string str;
int dx[4] = {-1,1,0,0},dy[4] = {0,0,-1,1};
// __int128//最大可用整数类型
// struct Node {
//     int l,r;
//     bool operator<(const Node &u) const {
//         return l < u.l;
//     }
// }node[N];
 
LL qmi(LL a,LL b,LL p) {LL res = 1;while(b) {if(b&1) res = (LL)res*a%p;a = (LL)a*a%p;b >>= 1;}return res%p;}
LL gcd(LL a,LL b) {return b ? gcd(b,a%b) : a;}
LL lcm(LL a,LL b) {return (LL)a*b / gcd(a,b);}
LL lowbit(LL x) {return x & -x;}
void print(ll x) {
    if(x<0) putchar('-'),x = -x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
// const int M = 3.2e3 + 10;
// int primses[M],cnt,val[N],res[N];
// bool st[M];
// void gar() {
//     for(int i = 2;i <= M;i ++) {
//         if(!st[i]) primses[cnt ++] = i;
//         for(int j = 0;primses[j]*i <= M;j ++) {
//             st[primses[j]*i] = true;
//             if(i%primses[j]==0) break;
//         }
//     }
// }
// const int M = 2e5+10;
// LL fact[M],infact[M];
// void cmb() {
//     fact[0] = infact[0] = 1;
//     for(int i = 1;i < M;i ++) fact[i] = fact[i-1]*i%mod;
//     infact[M-1] = qmi(fact[M-1],mod-2,mod)%mod;
//     for(int i = M-2;i >= 0;i --) infact[i] = infact[i+1]*(i+1)%mod;
// }
// LL C(int a,int b) {
//     if(a<b) return 0;
//     return (LL)fact[a]*infact[b]%mod*infact[a-b]%mod;
// }    

void solve() {
    int n;
    std::cin >> n;
 
    std::vector<int> a(n), b(n);
    for (int i = 0; i < n; i++)
        std::cin >> a[i], a[i]--;
    for (int i = 0; i < n; i++)
        std::cin >> b[i], b[i]--;
 
    std::vector<int> L(n);
    for (int i = 0; i < n; i++) {
        L[b[i]] = b[(i + n - 1) % n];
    }
 
    std::vector<int> res;
    for (int _ = 0; _ < n; _++) {
        int base = a[0];
 
        // 将L[a[0]]旋转到头
        auto pos = std::find(a.begin(), a.end(), L[base]);
        res.insert(res.end(), pos - a.begin(), 1);
        std::rotate(a.begin(), pos, a.end());
 
        // 将刚刚的a[0]旋转到1
        pos = std::find(a.begin(), a.end(), base);
        res.insert(res.end(), pos - a.begin() - 1, 2);
        std::rotate(a.begin() + 1, pos, a.end());
    }
 
    // 最后旋转到和答案一样
    auto pos = std::find(a.begin(), a.end(), b[0]);
    res.insert(res.end(), pos - a.begin(), 1);
    std::rotate(a.begin(), pos, a.end());
 
    for(auto u : res) cout << u;
    std::cout << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int T;
    cin >> T;
    while(T --) { 
        solve();
    }
    // solve();
       
    return 0;
}  
/*   /\_/\
*   (= ._.)
*   / >  \>
*/

Details

answer.code:136:11: error: redefinition of ‘const int N’
  136 | const int N = 2e5 + 10,mod =  1e9+7,P = 131;
      |           ^
answer.code:16:11: note: ‘const int N’ previously defined here
   16 | const int N = 2e5 + 10,mod =  1e9+7,P = 131;
      |           ^
answer.code:136:24: error: redefinition of ‘const int mod’
  136 | const int N = 2e5 + 10,mod =  1e9+7,P = 131;
      |                        ^~~
answer.code:16:24: note: ‘const int mod’ previously defined here
   16 | const int N = 2e5 + 10,mod =  1e9+7,P = 131;
      |                        ^~~
answer.code:136:37: error: redefinition of ‘const int P’
  136 | const int N = 2e5 + 10,mod =  1e9+7,P = 131;
      |                                     ^
answer.code:16:37: note: ‘const int P’ previously defined here
   16 | const int N = 2e5 + 10,mod =  1e9+7,P = 131;
      |                                     ^
answer.code:137:10: error: redefinition of ‘const long long int inf’
  137 | const LL inf = 1e9+10,INF = 1e18+10;
      |          ^~~
answer.code:17:10: note: ‘const long long int inf’ previously defined here
   17 | const LL inf = 1e9+10,INF = 1e18+10;
      |          ^~~
answer.code:137:23: error: redefinition of ‘const long long int INF’
  137 | const LL inf = 1e9+10,INF = 1e18+10;
      |                       ^~~
answer.code:17:23: note: ‘const long long int INF’ previously defined here
   17 | const LL inf = 1e9+10,INF = 1e18+10;
      |                       ^~~
answer.code:144:4: error: redefinition of ‘long long int n’
  144 | LL n,m,k;
      |    ^
answer.code:24:4: note: ‘long long int n’ previously declared here
   24 | LL n,m,k;
      |    ^
answer.code:144:6: error: redefinition of ‘long long int m’
  144 | LL n,m,k;
      |      ^
answer.code:24:6: note: ‘long long int m’ previously declared here
   24 | LL n,m,k;
      |      ^
answer.code:144:8: error: redefinition of ‘long long int k’
  144 | LL n,m,k;
      |        ^
answer.code:24:8: note: ‘long long int k’ previously declared here
   24 | LL n,m,k;
      |        ^
answer.code:145:8: error: redefinition of ‘std::string str’
  145 | string str;
      |        ^~~
answer.code:25:8: note: ‘std::string str’ previously defined here
   25 | string str;
      |        ^~~
answer.code:146:5: error: redefinition of ‘int dx [4]’
  146 | int dx[4] = {-1,1,0,0},dy[4] = {0,0,-1,1};
      |     ^~
answer.code:26:5: note: ‘int dx [4]’ previously defined here
   26 | int dx[4] = {-1,1,0,0},dy[4] = {0,0,-1,1};
      |     ^~
answer.code:146:24: error: redefinition of ‘int dy [4]’
  146 | int dx[4] = {-1,1,0,0},dy[4] = {0,0,-1,1};
      |                        ^~
answer.code:26:24: note: ‘int dy [4]’ previously defined here
   26 | int dx[4] = {-1,1,0,0},dy[4] = {0,0,-1,1};
      |                        ^~
answer.code:155:4: error: redefinition of ‘long long int qmi(long long int, long long int, long long int)’
  155 | LL qmi(LL a,LL b,LL p) {LL res = 1;while(b) {if(b&1) res = (LL)res*a%p;a = (LL)a*a%p;b >>= 1;}return res%p;}
      |    ^~~
answer.code:35:4: note: ‘long long int qmi(long long int, long long int, long long int)’ previously defined here
   35 | LL qmi(LL a,LL b,LL p) {LL res = 1;while(b) {if(b&1) res = (LL)res*a%p;a = (LL)a*a%p;b >>= 1;}return res%p;}
      |    ^~~
answer.code:156:4: error: redefinition of ‘long long int gcd(long long int, long long int)’
  156 | LL gcd(LL a,LL b) {return b ? gcd(b,a%b) : a;}
      |    ^~~
answer.code:36:4: note: ‘long long int gcd(long long int, long long int)’ previously defined here
   36 | LL gcd(LL a,LL b) {return b ? gcd(b,a%b) : a;}
      |    ^~~
answer.code:157:4: error: redefinition of ‘long long int lcm(long long int, long long int)’
  157 | LL lcm(LL a,LL b) {return (LL)a*b / gcd(a,b);}
      |    ^~~
answer.code:37:4: note: ‘long long int lcm(long long int, long long int)’ previously defined here
   37 | LL lcm(LL a,LL b) {return (LL)a*b / gcd(a,b);}
      |    ^~~
answer.code:158:4: error: redefinition of ‘long long int lowbit(long long int)’
  158 | LL lowbit(LL x) {return x & -x;}
      |    ^~~~~~
answer.code:38:4: note: ‘long long int lowbit(long long int)’ previously defined here
   38 | LL lowbit(LL x) {return x & -x;}
      |    ^~~~~~
answer.code:159:6: error: redefinition of ‘void print(__int128)’
  159 | void print(ll x) {
      |      ^~~~~
answer.code:39:6: note: ‘void print(__int128)’ previously defined here
   39 | void print(ll x) {
      |      ^~~~~
answer.code:189:6: error: redefinition of ‘void solve()’
  189 | void solve() {
      |      ^~~~~
answer.code:69:6: note: ‘void solve()’ previously defined here
   69 | void solve() {
      |      ^~~~~
answer.code:228:5: error: redefinition of ‘int main()’
  228 | int main() {
      |     ^~~~
answer.code:107:5: note: ‘int main()’ previously defined here
  107 | int main() {
      |     ^~~~