夏のN Tianle [記事]ゲーム--2019ハング電動マルチ学校の夏合宿(6位)

I胡閑山とロールバックは....タイトルの貯蔵寿命は、それを記述する必要がありました。

以下の説明は、次のとおりです。

\ [1002【HDU-6635】【1005 \\ HDU-6638】【1006 \\ HDU-6639】【1008 \\ HDU-6641】【1012 \\ HDU-6645 [\]

[1002] LIS +暴力HDU-6635ナンセンス時間

http://acm.hdu.edu.cn/showproblem.php?pid=6635

参考:https://blog.csdn.net/henuyh/article/details/98845165

所定の長さ\(N- \) 2つの配列の\(A、B \)、\ (B_i \)を表す\(\)の添え字で\(B_i \)を求めて、現在利用可能な数である\(B_iを\)対応\(\)を LISに\(\)される(\ [1、N] \ ) 、フルアレイ。

データがランダムに生成されるので、LIS所望の長さ\(\のSQRT {N-} \) としてLIS内の要素を削除する確率\(\ FRAC {\のSQRT {N-}} \ {1})ので、全体的な複雑。\(O(N \} N-SQRT {ログ(N)))\) 最初から配列を前方その後、LISのすべてを見つけると、\(のb \) あなたはそれの一つの要素を削除する場合LISで再評価されます。あなたはLISのパスを記録する必要があります。

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

const int maxn = 5e4+5;

int n;
int a[maxn];
int b[maxn];
int vis[maxn];
int ans[maxn];
int temp[maxn];
int path[maxn];
int used[maxn];

int solve() {
    int len = 0;
    for(int i = 1; i <= n; i++) {
        if(vis[a[i]] == 1) {
            continue;
        }
        int x = lower_bound(temp, temp+len, a[i]) - temp;
        if(x == len) {
            temp[len++] = a[i];
            path[i] = len;
        }
        else {
            temp[x] = a[i];
            path[i] = x + 1;
        }
    }
    memset(used, 0, sizeof(used));
    int x = len;
    for(int i = n; i >= 1; i--) {
        if(vis[a[i]] == 1) {
            continue;
        }
        if(path[i] == x) {
            used[a[i]] = 1;
            x--;
        }
    }
    return len;
}

int main() {
    int t;
    scanf("%d", &t);
    while(t--) {
        memset(vis, 0, sizeof(vis));
        scanf("%d", &n);
        for(int i = 1; i <= n; i++) {
            scanf("%d", &a[i]);
        }
        for(int i = 1; i <= n; i++) {
            scanf("%d", &b[i]);
        }
        ans[n] = solve();
        for(int i = n-1; i >= 1; i--) {
            vis[a[b[i+1]]] = 1;
            if(used[a[b[i+1]]] == 0) {
                ans[i] = ans[i+1];
            }
            else {
                ans[i] = solve();
            }
        }
        for(int i = 1; i <= n; i++) {
            printf("%d%c", ans[i], i==n?'\n':' ');
        }
    }
    return 0;
}

[1005]セグメントツリーHDU-6638雪スマイル

http://acm.hdu.edu.cn/showproblem.php?pid=6638

参考:https://blog.csdn.net/A_Thinking_Reed_/article/details/98778260

所与\(N(\当量2000) \) の重みと対応する座標点、最大値と重み行列を見つけます。

すべての列挙上下の境界、各セグメントツリーは少しを追加し、維持最大上下の境界内のサブセグメントと [範囲]と最大サブセグメントを、現在に直線境界移動でいくつかの点に注意を払う必要がある可能性があり、同じ境界上の全ての点が更新されている必要があります後に更新するための下側の境界を移動するときに\(ANS \)

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

const int maxn = 2e3+5;

struct node{
    int x, y;
    ll val;
    bool operator < (const node &q) const {
        if(y == q.y) {
            return x < q.x;
        }
        return y > q.y;
    }
}p[maxn];

struct NODE {
    ll sum, lsum, rsum, maxsum;
}T[maxn << 2];

int n; 
vector<int> vx, vy;

int get_xid(int x) {
    return lower_bound(vx.begin(), vx.end(), x) - vx.begin() + 1;
}

int get_yid(int y) {
    return lower_bound(vy.begin(), vy.end(), y) - vy.begin() + 1;
}

void pushup(int rt) {
    T[rt].sum = T[rt<<1].sum + T[rt<<1|1].sum;
    T[rt].lsum = max(T[rt<<1].lsum, T[rt<<1].sum + T[rt<<1|1].lsum);
    T[rt].rsum = max(T[rt<<1|1].rsum, T[rt<<1|1].sum + T[rt<<1].rsum);
    T[rt].maxsum = max(T[rt<<1].rsum+T[rt<<1|1].lsum, max(T[rt<<1].maxsum, T[rt<<1|1].maxsum));
}

void build(int l, int r, int rt) {
    T[rt].sum = T[rt].lsum = T[rt].rsum = T[rt].maxsum = 0;
    if(l == r) {
        return ;
    }
    int mid = (l+r) >> 1;
    build(l, mid, rt<<1);
    build(mid+1, r, rt<<1|1);
    pushup(rt);
}

void update(int l, int r, int pos, int val, int rt) {
    if(l == r) {
        T[rt].sum = T[rt].lsum = T[rt].rsum = T[rt].maxsum = T[rt].sum+val;
        return ;
    }
    int mid = (l+r) >> 1;
    if(pos <= mid) {
        update(l, mid, pos, val, rt<<1);
    }
    else {
        update(mid+1, r, pos, val, rt<<1|1);
    }
    pushup(rt);
}

int main() {
    int t;
    scanf("%d", &t);
    while(t--) {
        vx.clear();
        vy.clear();
        scanf("%d", &n);
        for(int i = 1; i <= n; i++) {
            scanf("%d%d%lld", &p[i].x, &p[i].y, &p[i].val);
            vx.push_back(p[i].x);
            vy.push_back(p[i].y);
        }
        sort(vx.begin(), vx.end());
        vx.erase(unique(vx.begin(), vx.end()), vx.end());
        sort(vy.begin(), vy.end());
        vy.erase(unique(vy.begin(), vy.end()), vy.end());
        int new_n = vx.size();
        for(int i = 1; i <= n; i++) {
            p[i].x = get_xid(p[i].x);
            p[i].y = get_yid(p[i].y);
        }
        sort(p+1, p+1+n);
        ll ans = 0;
        int lst_y = -1;
        for(int i = 1; i <= n; i++) {
            if(lst_y == p[i].y) {
                continue;
            }
            build(1, new_n, 1);
            for(int j = i; j <= n; ) {
                int k;
                for(k = j; k <= n && p[k].y == p[j].y; k++) {
                    update(1, new_n, p[k].x, p[k].val, 1);
                }
                ans = max(ans, T[1].maxsum);
                j = k;
            }
            lst_y = p[i].y;
        }
        printf("%lld\n", ans);
    }
    return 0;
}

[1006] HDU-6639ファラウェイを考えます

http://acm.hdu.edu.cn/showproblem.php?pid=6639

そこ\(N \) 二次元の点(兵士)座標、それらが共通の宛先有する\((X_ {E}に、Y_ {E})\) 知っている\(x_e \)\(y_e \)である([0、M] \) \ 範囲で、だけ彼らの位置を知っている\((X_I、Y_I)\ ) 目標である場合、約((\ | X_ {I} -x_ {E}を| + | Y_ {I} -y_ {E} |)\%K_ {I} = T_ {I} \) 今どのように多くの可能な目標を尋ねる)\ \((x_e、y_e)

\(| X_I - x_eは| + | Y_I - y_eは| \) の絶対値を除去し、各点\((X_I、Y_I)\ ) は、4つの平面部への総分割される\(N ^ 2 \)地域。列挙各領域、領域は、エンドポイント数を計算することができます。ので\(LCM(2 ,. 3 ,. 4 ,. 5)= 60 \) これだけに列挙する必要\(x_eを\)\(y_e \)残り60をダイ、\(O(N)\)実現可能性を判断します。

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int n, m;
vector<int> vx, vy;

struct node {
    int x, y;
    int k, t;
}p[15];

int check(int a, int b) {
    for(int i = 1; i <= n; i++) {
        if((abs(a-p[i].x)+abs(b-p[i].y))%p[i].k != p[i].t) {
            return 0;
        }
    }
    return 1;
}

int cal(int x, int y) {
    if(y-x-1 < 0) {
        return 0;
    }
    return ((y-x-1)/60) + 1; 
}

int main() {
    int t;
    scanf("%d", &t);
    while(t--) {
        vx.clear();
        vy.clear();
        scanf("%d%d", &n, &m);
        for(int i = 1; i <= n; i++) {
            scanf("%d%d%d%d", &p[i].x, &p[i].y, &p[i].k, &p[i].t);
            vx.push_back(p[i].x);
            vy.push_back(p[i].y);
        }
        vx.push_back(0);
        vx.push_back(m+1);
        vy.push_back(0);
        vy.push_back(m+1);
        sort(vx.begin(), vx.end());
        vx.erase(unique(vx.begin(), vx.end()), vx.end());
        int nx = vx.size();
        sort(vy.begin(), vy.end());
        vy.erase(unique(vy.begin(), vy.end()), vy.end());
        int ny = vy.size();
        ll ans = 0;
        for(int i = 0; i < nx-1; i++) {
            for(int j = 0; j < ny-1; j++) {
                for(int k = 0; k < 60; k++) {
                    for(int l = 0; l < 60; l++) {
                        if(check(vx[i]+k, vy[j]+l)) {
                            ans += 1ll*cal(vx[i]+k, vx[i+1])*cal(vy[j]+l, vy[j+1]);
                        }
                    }
                }
            }
        }
        printf("%lld\n", ans);
    }   
    return 0;
}

[1008]数学HDU-6641 TDL

http://acm.hdu.edu.cn/showproblem.php?pid=6641

彼のチームメイト、そして醤油によって書かれました。

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
#define lson node<<1
#define rson node<<1|1
using namespace std;
typedef long long ll;

const ll inf = 2e18;
const ll mod = 998244353;
const int maxn = 1e5 + 20;


ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}


int main() {
    int t;
    scanf("%d", &t);
    while (t--) {
        ll k, m;
        scanf("%lld%lld", &k, &m);
        ll ans = inf;
        int flag = 0;
        for (int i = 1; i <= 2000; i++) {
            ll n = k ^ i;
            int cnt = 0;
            int j = 1;
            for (; j <= 1000; j++) {
                if (gcd(j + n, n) == 1) {
                    cnt++;
                    if (cnt == m)
                        break;
                }
            }
            if ((n + j) == (i + n)) {
                ans = min(ans, n);
                flag = 1;
            }
        }
        if (flag)
            printf("%lld\n", ans);
        else
            printf("-1\n");
    }
}

[1012]水のタイトルHDU-6645順列2

http://acm.hdu.edu.cn/showproblem.php?pid=6645

試合時間がトポロジを書くために、なぜ私は知りません...

ライン上の配列を行に一個のポイント。

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int a[100005];

int main() {
    int t;
    scanf("%d", &t);
    while(t--) {
        int n;
        scanf("%d", &n);
        for(int i = 0; i < n; i++) {
            scanf("%d", &a[i]);
        }
        sort(a, a+n);
        ll ans1 = 0, ans2 = 0;
        for(int i = n-1; i >= 0; i-=2) {
            ans1 = ans1 + 1ll*a[i];
        }
        for(int i = n-2; i >= 0; i-=2) {
            ans2 = ans2 + 1ll*a[i];
        }
        printf("%lld %lld\n", ans1, ans2);
    }
    return 0;
}

おすすめ

転載: www.cnblogs.com/Decray/p/11365864.html