1112

Dong God out of the title for the first time on the success of the card ... 200pts
A physical
description of the problem
physics class, nodgd a racking our brains, invented a shortest path algorithm: to make a no ball to each node in the graph,
each side making a rope, the rope length is the edge weights; start point corresponding to the shortest path problem pellets slowly put
on, and then measuring the distance to the starting point of each ball of the ball, to get the starting point of each shortest nodes. nodgd found that
this algorithm is very powerful - it's time complexity is O (1).
nodgd demonstrate this we intend to give the shortest path algorithm in the class, then the data generator generates a set of data, i.e., a
free edges node to FIG. nodgd found were selected shortest different starting point, rope always some loose
relaxation state, some of the rope is always under tension, sometimes remaining slack rope taut sometimes, so that the rope can be divided into
three categories. Now nodgd I want to know which category each rope?
Input format
input file phys.in.
The first line of two integers nm, showing the undirected graph nodes and edges.
Subsequently m rows, each row ABC three integers, denotes the i th node without connecting to the edges ab, a weight of c. Ensure that no
have heavy side and loopback.
Output format
output files phys.out.
M output lines, the output lines an integer x i, x respectively denote the slack rope always always, always stretched
tight, sometimes taut sometimes relaxation.
Sample 1 Input Output
file phys-sample1.in phys-sample1.ans below and hair.

Dong God is so specialized cancer card dij

See \ (n <= 500 \) adjacent to the main memory of FIG floyd chant dij processing spot where less multilateral

Then how each point if this point is the endpoint of an edge can discuss whether or not the shortest distance
if the discussion is not an end in the shortest side if there is otherwise not in
code:

//
#include<bits/stdc++.h>
using namespace std;
#define maxnn 510
#define ll long long 
#define inf 100000000000
bool is[250010],son[250010];
struct node {
    int st,en;
    ll l;
} ed[250010];
ll mapp[maxnn][maxnn];
int n,m;
ll x,y,z;
#define GC getchar()
inline int R() {
    char t;
    int x=0;
    int f=1;
    t=GC;
    while(!isdigit(t)) {
        if(t=='-') f=-1;
        t=GC;
    }
    while(isdigit(t)) {
        x=x*10+t-48;
        t=GC;
    }
    return x*f;
}
int main() {
    freopen("phys.in","r",stdin);
    freopen("phys.out","w",stdout);
    n=R();
    m=R();
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=n; j++) {
            if(i==j) continue;
            mapp[i][j]=inf;
        }
    }
    for(int i=1; i<=m; i++) {
        ed[i].st=R();
        ed[i].en=R();
        ed[i].l=R();
        mapp[ed[i].st][ed[i].en]=mapp[ed[i].en][ed[i].st]=ed[i].l;
    }
    for(int k=1; k<=n; k++) {
        for(int i=1; i<=n; i++) {
            for(int j=1; j<=n; j++) {
                if(mapp[i][j]>mapp[i][k]+mapp[k][j]) {
                    mapp[i][j]=mapp[i][k]+mapp[k][j];
                }
            }
        }
    }
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++) {
            if(ed[j].st==i) {
                if(mapp[i][ed[j].en]==ed[j].l) {
                    is[j]=true;
                    continue;
                }
                continue;
            }
            if(ed[j].en==i) {
                if(mapp[i][ed[j].st]==ed[j].l) {
                    is[j]=true;
                    continue;
                }
                continue;
            }
            if(mapp[i][ed[j].en]+ed[j].l==mapp[i][ed[j].st]) {
                is[j]=true;
                continue;
            }
            if(mapp[i][ed[j].st]+ed[j].l==mapp[i][ed[j].en]) {
                is[j]=true;
                continue;
            }
            son[j]=true;
        }
    }
    for(int i=1; i<=m; i++) {
        if((!is[i])&&son[i]) {
            printf("1\n");
            continue;
        }
        if(is[i]&&(!son[i])) {
            printf("2\n");
            continue;
        }
        if(is[i]&&(son[i])) {
            printf("3\n");
            continue;
        }
    }
}

B. mathematics
(math.c / .cpp / .in / .out )
Problem Description
solid mathematical foundation is one of the basic qualities of each informatics contestants must have.
Calculating a positive integer such as the number n of about positive numbers, the usual practice is to first prime factor decomposition of n, each prime factor of
a power of synergistic after it.
Now nodgd give you a sequence of positive integers i, k, and asked many times: before the sequence number of the product i have
all prime factors of the number of positive divisors does not exceed k it? In particular, there is no prime factor 1, so no matter how inquiries are always
eligible.
Input format
input file math.in.
The first line of two integers, the number and length of the query sequence representation.
The second line of positive integers.
From the third row from the successive lines of two positive integers, it represents a query.
Output Format

Solution:
Fenwick tree maintenance prefix product .... saying lhd said I can do intervals gcd no thought of how ...Because I hit O (sqrt (n)) also found himself making the limit data run really fast (Sqrt (n)) I really badly decomposed

You must put their ideas down or will forget his past thought about the idea ...

C. Biological
(biol.c / .cpp / .in / .out )
Description of the problem
a kind of biological ecosystems, which form the food chain and food web. Such organisms, some producers
do not need to eat other organisms can survive; some of the remaining consumers, must eat other organisms to survive.
The importance of the definition of an organism is, if this extinction, including itself will lead to extinction of many kinds.
Consumer 'creature, if it's all foods are extinct, the creatures will become extinct.
Aftereffect of an organism is defined as, if this extinction, extinction event triggered by time how many units will continue.
Consumer 'creature, if it's the last food extinct in units of time, it will be at the current time this unit
extinct.
The task now is to calculate the importance of each creature and after-effect.
Input format
input file biol.in.
The first line of two integers n, m, the number indicating the type and quantity of food related organisms.
Next m lines of two integers a, b, represents a kind of type b organisms may be for food organisms. Guarantee will not be
any kind of biological directly or indirectly, to eat their own situation, the same relationship to ensure that no repetition occurs. Do not eat any other biological
organisms are producers.
Output format
output files biol.out.
N output lines, two integers CD i-th row, respectively, and showing the importance of the second kind of biological aftereffects.
Sample 1 Input Output
file biol-sample1.in biol-sample1.ans below and hair.

Guess you like

Origin www.cnblogs.com/OIEREDSION/p/11841076.html