CCPC-Wannafly Summer Camp 2019 Full Record

 // 7.19-7.29 Qinhuangdao Northeastern University campus ten days of training camp, topics are hanging on Vjudge. During the busy training, no more empty Bo summary, come back to fill the title digest.

 // https://vjudge.net/contest/312902

https://vjudge.net/contest/313217

https://vjudge.net/contest/313584

https://vjudge.net/contest/314412

https://vjudge.net/contest/314730

https://vjudge.net/contest/314974

Day1

That day taught theme is simple graph theory, rhythm is very good, wls two hours Jimmy End of graph theory in the basics of points.

The afternoon title match on the side of the entry ( simple graph theory no doubt), involving only the shortest path problem and simple search, and some strange tricks. (Differential limitation? Minimum spanning tree it? Strongly connected component of it?)

A - Jzzhu and Cities (补)

#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int maxn = 200010;
struct Edge {
    int to;
    bool istrain;
    ll w;
    Edge(int v, bool is, ll ww):to(v), istrain(is), w(ww){}
    bool operator<(const Edge& a)const {
        if(w==a.w) return istrain;  // 非火车节点先更新
        return w > a.w;
    }
};
vector<Edge> G[maxn];

bool vis[maxn];
int d[maxn];

int Dijkstra() {
    memset(d, 0x3f, sizeof(d));
    memset(vis, 0, sizeof(vis));
    d[1] = 0;
    int res = 0;

    priority_queue<Edge> q;
    q.push(Edge(1, 0, 0));
    while(!q.empty()) {
        Edge tmp = q.top(); q.pop();
        int u = tmp.to;
        if(vis[u]) continue;

        vis[u] = 1;
    //    d[u] = tmp.w;
        if(tmp.istrain) ++res;

        for(int i=0;i<G[u].size();i++) {
            int v = G[u][i].to;
            if(!vis[v] && d[v]>=d[u]+G[u][i].w) {
                d[v] = d[u] + G[u][i].w;
                q.push(Edge(v, G[u][i].istrain, d[v]));
            }
        }

    }
    return res;

}

int main() {
    int n, m, k;
    cin>>n>>m>>k;
    int u, v, w;
    for(int i=0;i<m;i++) {
        scanf("%d %d %d", &u, &v, &w);
        G[u].push_back(Edge(v, 0, w));
        G[v].push_back(Edge(u, 0, w));
    }
    for(int i=0;i<k;i++) {
        scanf("%d %d", &v, &w);
        G[1].push_back(Edge(v, 1, w));
        // G[v].push_back(Edge(1, 1, w));
    }

    printf("%d\n", k-Dijkstra());

    return 0;
}
View Code

 

B -  Phillip and Trains   BFS note marking! ! ! (Although only 3 * 100 maps have burst memory!)

#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
int n, k, sx;
char mp[3][110];
bool vis[3][110];
struct node {
    int x, y;
    node(int _x, int _y):x(_x), y(_y) {}
};

bool check(int x, int y) {
    if(x<0 || x>2)
        return false;
    if(y>=n)
        return true;
    if(mp[x][y]=='.')
        return true;

    return false;
}

bool bfs() {
    queue<node> q;
    q.push(node(sx, 0));

    while(q.size()) {
        node now = q.front(); q.pop();
        if(now.y>=n) {
            return true;
        }

    //    the printf ( "(% D,% D) ->", now.x, now.y); 
        
        int NX = now.x, NY + = now.y . 1 ;
         IF (Check (NX, NY)!)   Continue ; / / go right step 

        for ( int I = - . 1 ; I <= . 1 ; I ++) {       // try to move in three directions 
            NX + = now.x I;
             IF (Check (NX, NY) && Check (NX, NY + . 1 ) && Check (NX, NY + 2 ) && VIS [NX] [NY +! 2 ]) { 
                q.push (Node (NX, NY + 2 )); 
                VIS [NX] [NY + 2 ] =1;
            }
        }
    }
    return false;
}


int main() {
    int t; cin>>t;
    while(t--) {
        scanf("%d %d", &n, &k);
        getchar();
        memset(vis, 0, sizeof(vis));
        for(int i=0;i<3;i++) {
            scanf("%s", mp[i]);
            
            if(mp[i][0]=='s')
                sx = i;
            
        }
        printf("%s\n", bfs()?"YES":"NO");
    }
    
    return 0;
}
View Code

 

 

Day2

Day3

Dy4

Day5

Day6

 

Guess you like

Origin www.cnblogs.com/izcat/p/11274543.html