여름 N Tianle [기사] 게임 --2019 끊기 전기 멀티 학교 여름 훈련 캠프 (제 6 호)

I 후 한산 롤 다시 .... 제목의 수명이 적어해야했다.

다음의 설명은 다음과 같습니다 :

\ [1,002 【HDU-6635】 【\\ HDU 1,005 - 6,638 1,006】 【\\ HDU-6639】 【1,008 \\ HDU-6641】 【1,012 \\ HDU-6645 [\]

[1002] LIS + 폭력 HDU-6635 넌센스 시간

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

참조 : https://blog.csdn.net/henuyh/article/details/98845165

의 주어진 길이 \ (\ N-) 두 배열의 \ (A, B \) , \ (B_i는 \) 대표 \ (A \) 첨자에서 \ (B_i이 \) 추구하는 현재 사용 가능한 숫자이다 \ (B_i를 \) 대응 \ (a \)를 LIS에 \ (a \하면) 이다 \ ([1, N] \ ) 의 전체 어레이.

데이터가 랜덤하게 생성되어 있기 때문에, LIS 원하는 길이 \ (\의 SQRT {N-} \) ,로 LIS 요소 삭제 확률 \ (\ FRAC {1.} {\의 SQRT {N-}} \) 때문에 전체적인 복잡도 : \ (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_ {난} -y_ {E} |) \ % K_ {난} = t_ {난} \) 를 요청할 지금 얼마나 많은 가능한 목표 \ ((x_e, y_e) \) .

\ (| x_i로부터 - x_e는 | + | y_i - y_e는 | \) 의 절대 값이 제거되고, 각 지점 (\ (x_i로부터, y_i) \ ) , 네 개의 평면 부에 총 분할한다 \ (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