Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=5386
A rather violent question backwards, and looked at the relationship with mathematics, but did not,
Don't think of it as a mathematical problem when you see a mathematical element in it, and it's possible to deduce it with programming ideas.
The problem is to do it backwards and violently, the problem of violence is not easy to debug,
Note that the input and output must not be problematic.
1#include <stdio.h>2 Const intMAXN1 = the;3 Const intMAXN2 =505;4 intT;5 intm, N;6 intA[MAXN1][MAXN1];7 CharOP[MAXN2];8 intope[maxn2][2];9 intMOP[MAXN2];Ten intT; One BOOLFlag; A Charch; - voidRead () { -scanf"%d%d",&n,&m); the for(inti =0; I < n; ++i) - for(intj =0; J < N; ++j) -scanf"%d",&a[i][j]); - for(inti =0; I < n; ++i) + for(intj =0; J < N; ++j) -scanf"%d",&a[i][j]); + for(inti =0; I < m; ++i) { ACH =GetChar (); at while(ch! ='H'&& ch! ='L') -CH =GetChar (); -Op[i] =ch; -scanf"%d%d", &ope[i][0],&ope[i][1]); - } - } in intMain () { - //freopen ("A.txt", "R", stdin); toscanf"%d",&T); + while(t--){ -t =0; the Read (); * while(t<m) { $ for(intK =0; K < M; ++k) {Panax Notoginseng if(ope[k][0]){ - if(Op[k] = ='H'){ theFlag =1; + for(inti =0; I < n; ++i) { A if(a[ope[k][0]-1][i]! = ope[k][1] && a[ope[k][0]-1][i]) { theFlag =0; + Break; - } $ } $ if(flag) { - for(inti =0; I < n; ++i) -a[ope[k][0]-1][i] =0; theope[k][0] =0; -mop[t++] =K;Wuyi } the } - if(Op[k] = ='L'){ WuFlag =1; - for(inti =0; I < n; ++i) { About if(a[i][ope[k][0]-1]! = ope[k][1] && a[i][ope[k][0]-1]){ $Flag =0; - Break; - } - } A if(flag) { + for(inti =0; I < n; ++i) { thea[i][ope[k][0]-1] =0; - } $mop[t++] =K; theope[k][0] =0; the } the } the } - } in } the for(inti = m1; I >=0; --i) { theprintf"%d", mop[i]+1); About if(I! =0 ) theprintf" "); the } theprintf"\ n"); + } -}
Hdoj 5386 Cover