Luogu1056 seat row

This is a water problem
originally thought and theory related, but a closer reading problems found sort + greedy can live out;
did not talk much on the code.

#include <bits / STDC ++ H.>
 the using  namespace STD;
 int m, n-, K, L, D;
 struct Node // structure 
{
 int Order;
 int Student; 
} X [ 1010 ], Y [ 1010 ]; 
inline int qread () // fast read, I just code with training practice; 
{
 int RES = 0 ; BOOL BO = 0 ; char C;
 the while (((C = getchar ()) < ' 0 ' || C> ' . 9 ' ) C &&! = '-');
if (c == '-') bo = 1; else res = c - 48;
while ((c = getchar()) >= '0' && c <= '9')
res = (res << 3) + (res << 1) + (c - 48);
return bo ? ~res + 1 : res;
}
bool cmp(node a,node b)//先按照说话人数排序
{
return a.student ==b.student ? a.order <b.order : a.student >b.student; 
} 
BOOL CMP1 (Node A, Node B) // output required, should sequentially output line, but also the discharge over 
{
 return a.order < b.order; 
} 
void Read () 
{ 
int x_1, Y_1 , P_1, Q_1; 

m = qread (); 
n- = qread (); 
K = qread (); 
L = qread (); 
D = qread ();
 for ( int I = . 1 ; I <= D; I ++ ) 
{ 
x_1 = qread (); 
Y_1 = qread (); 
P_1 =qread (); 
Q_1 = qread ();
 for ( int I = . 1 ; I <= m; I ++) X [I] .order = I;
 for ( int I = . 1 ; I <= n-; I ++) Y [I ] .order = I;
 IF (x_1 == P_1) // two people at the same row, the following denoted 
{ 
Y [min (Y_1, Q_1)] Student. ++; // to determine what size, small columns denoted 
}
 IF (Y_1 == Q_1) 
{ 
X [min (x_1, P_1)] Student. ++; // two peers, and as columns 
} 
} 
} 
int main () 
{ 
//     The freopen ( "testdata.in", " r ", stdin);
Read (); 
Sort (Y + . 1 , Y + n-+ . 1 , CMP); // number of press arrangement 
Sort (X + . 1 , X + . 1 + m, CMP); 
Sort (X + . 1 , X + K + . 1 , CMP1) ; // press line arranged in order or will WA, to experience; 
Sort (Y + . 1 , Y + L + . 1 , CMP1);
 for ( int I = . 1 ; I <= K; I ++ ) 
{ 
the printf ( " % D " , X [I] .order); 
} 
the printf ( " \ n- " );
 for ( int i=1;i<=l;i++)
{
printf("%d ",y[i].order );
}
return 0;
}

 

This konjac second 发题 solution wish Board 过吧! Thank you

Guess you like

Origin www.cnblogs.com/Shiina-Rikka/p/11223639.html
Row