SRM555
コンパイルエラーに悩んでいたらただ
using namespace std;
を書き忘れただけっていう。
早解きの練習が必要。
712 -> 715 (+3)
#include <cstdio> #include <iostream> #include <algorithm> #include <vector> #include <string> using namespace std; class XorBoardDivTwo{ public: int theMax(vector <string> board){ int h = board.size(); int w = board[0].length(); int n = 0; for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) if(board[i][j] == '1') n++; int ans = -1; for(int i = 0; i < h; i++){ int t = 0; for(int j = 0; j < w; j++){ if(board[i][j] == '1') t--; else t++; } for(int j = 0; j < w; j++){ int u = t; if(board[i][j] == '1') u += 2; else u -= 2; for(int k = 0; k < h; k++){ if(board[k][j] == '1') u--; else u++; } ans = max(ans, n+u); } } return ans; } };