Problem description: AI, Ni, OP string (both> and <), CI, S (AI) + S (AI + 1) + .... + S (AI + Ni)>/<Ci
Ask if such s exists
Solution: Difference constraint, Super Cup, I actually put s (AI) + S (AI + 1) + .... + S (AI + Ni) is represented as S (AI + Ni)-S [ai]. Obviously this is wrong and should be:
S (I) indicates the continuous sum of (not including I) before I, so the above formula should be represented as S (AI + Ni + 1)-S (AI)
In addition, because this question is strictly <and>, x-y <C must be expressed as W (Y, x) = C-1;
For other photos
# Include <cstdio> <br/> # include <cstdlib> <br/> # include <cstring> <br/> # include <queue> <br/> # include <cmath> <br/> # define INF 200000000 <br/> using namespace STD; <br/> const int maxn = 500*500; <br/> int n, m, U [maxn], V [maxn], first [maxn], W [maxn], next [maxn], d [maxn]; <br/> // int bellman_ford () </P> <p> void add_vertice () <br/>{< br/> Int & E = m; <br/> for (INT I = 1; I <= n + 1; I ++) <br/>{< br/> U [e] = n + 2; <br/> V [e] = I; <br /> W [e] = 0; <br/> next [e] = first [U [e]; <br/> first [U [e] = e ++; <br/>}< br/>}// notes: add 0 to the graph <br/> bool bellman_ford () // notes: is spfa <br/>{< br/> // printf ("###/ N"); <br/> bool INQ [maxn]; <br/> int inqnum [maxn]; <br/> // notes: is the number of the vertice entering <br/> // The queue <br/> queue <int> q; </P> <p> for (INT I = 1; I <= n + 1; I ++) d [I] = inf; <br/> d [n + 2] = 0; <br/> q. push (n + 2); <br/> memset (INQ, 0, sizeof (INQ); <br/> memset (inqnum, 0, sizeof (inqnum); <br/> inqnum [n + 2] = 1; <br/> while (! Q. empty () <br/>{< br/> int x = Q. front (); q. pop (); <br/> INQ [x] = false; <br/> for (int e = first [X]; e! =-1; E = next [e]) <br/> If (d [V [e]> d [x] + W [e]) <br/> {<br/> d [V [e] = d [x] + W [E]; <br/> If (! INQ [V [e]) <br/>{< br/> inqnum [V [e] ++; <br/> If (inqnum [V [e]> n + 2) return false; <br/> INQ [V [e] = true; <br/> q. push (V [e]); <br/>}< br/> return true; <br/>}< br/> int main () <br/>{< br/> int A, B, C; <br/> char fir, SEC; <br/> while (scanf ("% d", & n) = 1 & N) <br/>{< br/> memset (first,-1, sizeof (first); <br/> scanf ("% d", & M); <br/> for (int e = 0; e <m; e ++) <br/>{< br/> // scanf ("% d % C % d", & A, & B, & fir, & sec, & C); <br/> scanf ("% d", & A, & B); <br/> getchar (); <br/> scanf ("% C", & fir, & Sec); <br/> scanf ("% d", & C ); <br/> // scanf ("% d % C % d ",); <br/> // printf ("% d % C % d/N", a, B, fir, SEC, C ); <br/> If (FIR = 'G' & sec = 'T ') <br/>{< br/> U [e] = B + A + 1; <br/> V [e] =; <br/> W [e] =-C-1; <br/> next [e] = first [U [e]; <br/> first [U [e] = E; <br/>}< br/> else <br/>{< br/> U [e] =; <br/> V [e] = B + A + 1; <br/> W [e] = C-1; <br/> next [e] = first [U [e]; <br/> first [U [e] = E; <br/>}< br/> add_vertice (); <br/> // printf ("#### 3/N "); <br/> bool ans = bellman_ford (); <br/> If (ANS) printf ("lamentable Kingdom/N "); <br/> else printf ("successful conspiracy/N"); <br/>}< br/> // system ("pause"); <br/> return 0; </P> <p >}< br/>