码迷,mamicode.com
首页 > 其他好文 > 详细

臭大佬_LZW

时间:2019-12-10 10:23:41      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:its   ems   memset   sizeof   bit   gcc   using   ast   optimize   

SPJ

#pragma GCC optimize(2)
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define ll long long
#define met(a, x) memset(a,x,sizeof(a))
using namespace std;
const int N = 3e5 + 10;
int a[N], b[N], c[N];
map<int, int> mp;
//char argc[10][10100];
int main(int argc, char *args[]) {
    ifstream user, in, out;
    in.open(args[1]);//测试输入
    out.open(args[2]);//测试输出
    user.open(args[3]);//用户输出
    int n;
    in >> n;
    for (int i = 1; i <= n; i++) {
        in >> a[i + n];
        a[i] = a[i + n];
        a[i + 2 * n] = a[i + n];
    }
    for (int i = 1; i <= n; i++) {
        in >> b[i + n];
        b[i] = b[i + n];
        b[i + 2 * n] = b[i + n];
    }
    int ans;
    out >> ans;
    if (ans == -1) {
        int x;
        user>>x;
        if(x!=ans)return 1;
    } else {
        for (int i = 1; i <= n; i++) {
            user >> c[i];
            if (mp[c[i]])return 1;
            mp[c[i]]++;
        }
        int numa = 0, numb = 0;
        for (int i = 1; i <= n; i++) {
            if (a[i] == c[1])numa = i + n;
            if (b[i] == c[1])numb = i + n;
        }
        int l = numa - 1, r = numa + 1;
        for (int i = 2; i <= n; i++) {
            if (c[i] == a[l])l--;
            else if (c[i] == a[r])r++;
            else return 1;
        }
        l = numb - 1, r = numb + 1;
        for (int i = 2; i <= n; i++) {
            if (c[i] == b[l])l--;
            else if (c[i] == b[r])r++;
            else return 1;
        }
    }
    return 0;
}

 

臭大佬_LZW

标签:its   ems   memset   sizeof   bit   gcc   using   ast   optimize   

原文地址:https://www.cnblogs.com/nublity/p/12015026.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!