zoukankan      html  css  js  c++  java
  • HEOI2013 ALO

    题目链接:戳我

    我竟然还有脸发出这样一篇题解.......

    其实我是暴力水过去的,,就从一个点开始,找它两边的数和它异或,不断更新答案。如果一侧找到第二个比它大的数,就break掉......

    正解是可持久化01trie,但是我写出锅了,正在咕咕咕,写出来了之后一定update

    暴力AC代码如下:

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<cmath>
    #define MAXN 100010
    using namespace std;
    int n,ans;
    int a[MAXN];
    inline void solve(int x)
    {
        int cur_ans=0,cnt;
        cnt=0;
        for(int i=x-1;i>=1;i--)
        {
            if(cnt>1) break;
            if(a[i]>a[x]) cnt++;
            cur_ans=max(cur_ans,a[i]^a[x]);
        }
        cnt=0;
        for(int i=x+1;i<=n;i++)
        {
            if(cnt>1) break;
            if(a[i]>a[x]) cnt++;
            cur_ans=max(cur_ans,a[i]^a[x]);
        }
        ans=max(ans,cur_ans);
    }
    int main()
    {
        #ifndef ONLINE_JUDGE
        freopen("ce.in","r",stdin);
        #endif
        scanf("%d",&n);
        for(int i=1;i<=n;i++) scanf("%d",&a[i]);
        for(int i=1;i<=n;i++) solve(i);
        printf("%d
    ",ans);
        return 0;
    }
    
    
  • 相关阅读:
    HDU 1058 Humble Numbers
    HDU 1421 搬寝室
    HDU 1176 免费馅饼
    七种排序算法的实现和总结
    算法纲要
    UVa401 回文词
    UVa 10361 Automatic Poetry
    UVa 537 Artificial Intelligence?
    UVa 409 Excuses, Excuses!
    UVa 10878 Decode the tape
  • 原文地址:https://www.cnblogs.com/fengxunling/p/10909255.html
Copyright © 2011-2022 走看看