Topic Portal
1 /*2 Test Instructions: Delete several rows so that n-line strings are sorted incrementally3 Brute Force + construct: Enumerates the columns from the previous, when the previous order is correct, then does not have to consider, so that the deletion of the smallest4 */5 /************************************************6 Author:running_time7 Created time:2015-8-3 10:49:538 File name:c.cpp9 *************************************************/Ten One#include <cstdio> A#include <algorithm> -#include <iostream> -#include <sstream> the#include <cstring> -#include <cmath> -#include <string> -#include <vector> +#include <queue> -#include <deque> +#include <stack> A#include <list> at#include <map> -#include <Set> -#include <bitset> -#include <cstdlib> -#include <ctime> - using namespacestd; in - #defineLson L, Mid, RT << 1 to #defineRson mid + 1, R, RT << 1 | 1 +typedefLong Longll; - Const intMAXN = 1e2 +Ten; the Const intINF =0x3f3f3f3f; * Const intMOD = 1e9 +7; $ CharS[MAXN][MAXN];Panax Notoginseng intN, M; - BOOLOK[MAXN][MAXN]; the + intMainvoid) {//codeforces Round #283 (Div. 2) C. Removing Columns A while(SCANF ("%d%d", &n, &m) = =2) { the for(intI=1; i<=n; ++i) { +scanf ("%s", S[i] +1); - } $ intAns =0; Memset (OK,false,sizeof(OK)); $ BOOLFlag =true; - for(intj=1; j<=m; ++j) { -Flag =true; the for(intI=2; i<=n; ++i) { - if(ok[i][i-1])Continue;Wuyi if(S[i][j] < s[i-1][j]) { theans++; Flag =false; Break; - } Wu } - if(flag) { About for(intk=2; k<=n; ++k) { $ if(S[k][j] > s[k-1][J]) ok[k][k-1] =true; - } - } - } Aprintf ("%d\n", ans); + } the - return 0; $}
Violence + construction Codeforces Round #283 (Div. 2) C. Removing Columns