New Year Celebrations ~ ~ ~

Source: Internet
Author: User


Listening to people say that information classes should celebrate the new year in different ways

Whoa, click!

You can only celebrate it in a unique way ...
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <locale>
#include <memory>
#include <stdexcept>
#include <utility>
#include <string>
using namespace Std;
const char hello[27]={', ' H ', ' a ', ' P ', ' P ', ' y ', ' \ n ', ' n ', ' e ', ' w ', ' ', ' y ', ' e ', ' a ', ' R ', '! '};
const int max=10100;
const int inf=1000000000;
struct EDGE
{
int v,c,next;
}EDGE[101000];
int E,head[max];
int Gap[max],cur[max];
int Pre[max],dis[max];
void Add_edge (int s,int t,int c,int cc)
{
edge[e].v=t; Edge[e].c=c;
Edge[e].next=head[s];
head[s]=e++;
Edge[e].v=s; EDGE[E].C=CC;
EDGE[E].NEXT=HEAD[T];
head[t]=e++;
}
int min (int a,int b) {return (a==-1| | b<a)? B:a;}
int SAP (int s,int t,int N)
{
memset (Gap,0,sizeof (GAP));
memset (dis,0,sizeof (dis));
int i;
for (i=0;i<n;i++) cur[i]=head[i];
int u=pre[s]=s,maxflow=0,aug=-1,v;
Gap[0]=n;
while (Dis[s]<n)
{
Loop:for (I=cur[u];i!=-1;i=edge[i].next)
{
V=EDGE[I].V;
if (edge[i].c>0&&dis[u]==dis[v]+1)
{
Aug=min (AUG,EDGE[I].C);
Pre[v]=u;
Cur[u]=i;
U=v;
if (u==t)
{
for (U=pre[u];v!=s;v=u,u=pre[u])
{
Edge[cur[u]].c-=aug;
Edge[cur[u]^1].c+=aug;
}
Maxflow+=aug;
Aug=-1;
}
Goto Loop;
}
}
int mindis=n;
for (I=head[u];i!=-1;i=edge[i].next)
{
V=EDGE[I].V;
if (Edge[i].c>0&&dis[v]<mindis)
{
Cur[u]=i;
MINDIS=DIS[V];
}
}
if ((--gap[dis[u]) ==0) break;
gap[dis[u]=mindis+1]++;
U=pre[u];
}
return maxflow;
}
int m, n, S, T;
int sum_row[210], sum_col[210];
int low[210][210], up[210][210], in[10010];
BOOL Judge (int i,int J,char op,int c)
{
if (op== ' = ')
{
if (c >= low[i][j] && C <= Up[i][j])
{
LOW[I][J] = c;
UP[I][J] = c;
}
else return false;
}
else if (op== ' > ')
{
LOW[I][J] = max (low[i][j],c+1);
if (Low[i][j] > Up[i][j]) return false;
}
Else
{
Up[i][j] = min (up[i][j],c-1);
if (Low[i][j] > Up[i][j]) return false;
}
return true;
}
BOOL Init ()
{
e=0;
memset (head,-1,sizeof (head));
memset (In,0,sizeof (in));
int I, j, K, A, B, C;
scanf ("%d%d", &m,&n);
int tot = 2 * n * m;
S = 0; T = tot + n + m + 1;
for (i = 1; I <= m; i++)
{
scanf ("%d", &sum_row[i]);
In[i+tot] = Sum_row[i];
In[s]-= sum_row[i];
}
for (i = 1; I <= n; i++)
{
scanf ("%d", &sum_col[i]);
In[t] + = Sum_col[i];
In[m+tot+i] =-sum_col[i];
}
Add_edge (t,s,inf,0);
scanf ("%d", &k); Char op[5];
for (i = 1; l <= m; i++) for (j = 1; J <= N; j + +) Low[i][j] = 0, up[i][j] = 200000;
BOOL flag = TRUE;
for (int x = 0; x < K; × x + +)
{
scanf ("%d%d%s%d", &a,&b,op,&c);
if (!a)
{
if (!b)
{
for (i = 1; I <= m; i++)
{
for (j = 1; J <= N; j + +)
{
if (!judge (i,j,op[0],c)) flag = false;
}
}
}
Else
{
for (i = 1; I <= m; i++)
{
if (!judge (i,b,op[0],c)) flag = false;
}
}
}
Else
{
if (!b)
{
for (i = 1; I <= n; i++)
{
if (!judge (a,i,op[0],c)) flag = false;
}
}
Else
{
if (!judge (a,b,op[0],c)) flag = false;
}
}
}
return flag;
}
int ID (int i,int j)
{
Return (i-1) *n+j;
}
int ans[250][250];
BOOL Check ()
{
for (int i = 1; I <= m; i++)
{
int s = 0;
for (Int J =1; J <=n;j + +)
{
s + = Ans[i][j];
}
if (S!=sum_row[i]) return false;
}
for (int i = 1; I <= n; i++)
{
int s = 0;
for (int j = 1; j <= M; j + +)
{
s + = Ans[j][i];
}
if (S!=sum_col[i]) return false;
}
return true;
}
BOOL Solve ()
{
int I, j, K;
for (i = 1; I <= m; i++)
{
for (j = 1; J <= N; j + +)
{
int c = up[i][j]-low[i][j];
int id = ID (i,j);
Add_edge (id,id+n*m,c,0);
In[id]-= low[i][j];
In[id+n*m] + = low[i][j];
}
}
int SS = T + 1, tt = SS + 1;
for (i = 1; I <= m; i++)
{
for (j = 1; J <= N; j + +)
{
Add_edge (2*n*m+i,id (i,j), 200000,0);
}
}
for (i = 1; I <= n; i++)
{
for (j = 1; j <= M; j + +)
{
Add_edge (ID (j,i) +m*n,2*m*n+m+i,200000,0);
}
}
for (i = 0; I <= 2*m*n+m+n+1; i++)
{
if (In[i] > 0) add_edge (ss,i,in[i],0);
if (In[i] < 0) Add_edge (i,tt,-in[i],0);
}
SAP (ss,tt,tt+1);
for (I=head[ss];i!=-1;i=edge[i].next)
{
if (EDGE[I].C) return false;
}
for (i = 1; I <= m; i++)
{
for (j = 1; J <= N; j + +)
{
int id = ID (i,j);
for (k = head[id]; k!=-1; k=edge[k].next)
{
if (edge[k].v <= 2*n*m)
{
ANS[I][J] = low[i][j] + edge[k^1].c;
}
}
}
}
for (i = 1; I <= m; i++)
{
printf ("%d", ans[i][1]);
for (j = 2; J <= N; j + +)
{
printf ("%d", ans[i][j]);
}
Puts ("");
}
return true;
}
int main ()
{
while (true) {
for (int i=1;i<=16;++i)
printf ("%c", Hello[i]);
printf ("\ n");
}
return 0;
}

New Year Celebrations ~ ~ ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.