Task: | Aliruudukot |
Sender: | Aaron Äärelä |
Submission time: | 2020-02-09 16:22:40 +0200 |
Language: | C++ (C++11) |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp:3:1: error: expected ';' before 'int' int h, w; ^~~ input/code.cpp: In function 'int t(int, int, int)': input/code.cpp:8:26: error: 'int t(int, int, int)' redeclared as different kind of symbol int t(int x, int y, int k){ ^ input/code.cpp:5:6: note: previous declaration 'char t [1000][1000]' char t[1000][1000]; ^ input/code.cpp:12:35: error: 't' cannot be used as a function if(x != wt) if(!t(x + 1, y, k + 1)) return 0; ^ input/code.cpp:13:35: error: 't' cannot be used as a function if(y != ht) if(!t(x, y + 1, k + 1)) return 0; ^ input/code.cpp: In function 'int main()': input/code.cpp:31:18: error: 't' cannot be used as a function if(t(x1, y1, 0)) ms = s; ^
Code
#include <bits/stdc++.h> using namespace std int h, w; int ht, wt; char t[1000][1000]; int fs = 0; char f[10000]; int t(int x, int y, int k){ if(fs && t[y][x] != f[k]) return 0; if(!fs) f[k] = t[y][x]; if(x == wt && y == ht) fs = 1; if(x != wt) if(!t(x + 1, y, k + 1)) return 0; if(y != ht) if(!t(x, y + 1, k + 1)) return 0; return 1; } int main(){ cin >> h >> w; for(int i = 0; i < h; i++){ for(int j = 0; j < w; j++){ cin >> t[i][j]; } } int ms = 0; for(int y1 = 0; y1 < h; y1++){ for(int x1 = 0; x1 < w; x1++){ for(int y2 = y1; y2 < h; y2++){ for(int x2 = x1; x2 < w; x2++){ int s = (x2 - x1 + 1) * (y2 - y1 + 1); if(s <= ms) continue; fs = 0; if(t(x1, y1, 0)) ms = s; } } } } cout << ms << '\n'; return 0; }