Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
using namespace std; ifstream fin("art.in"); ofstream fout("art.out"); const int nmax = 10; int n; int c[nmax + 1][nmax + 1]; struct BoundingBox { int xmin = 1e9, ymin = 1e9; int xmax = 0, ymax = 0; } bb[nmax + 1]; void update(BoundingBox& bb, int x, int y) { bb.xmin = min(bb.xmin, x); bb.ymin = min(bb.ymin, y); bb.xmax = max(bb.xmax, x); bb.ymax = max(bb.ymax, y); } bool ok[nmax + 1]; int main() { fin >> n; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { char ch; fin >> ch; c[i][j] = ch - '0'; if (c[i][j] == 0) { continue; } ok[c[i][j]] = true; update(bb[c[i][j]], i, j); } } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { if (c[i][j] == 0) { continue; } for (int k = 1; k <= 9; ++k) { if (k == c[i][j]) { continue; } // vreau sa vad daca (i, j) este inclusa in bounding boxul culorii k if (bb[k].xmin <= i && i <= bb[k].xmax && bb[k].ymin <= j && j <= bb[k].ymax) { // culoarea c[i][j] a fost pusa dupa culoarea k ok[c[i][j]] = false; } } } } fout << count(ok + 1, ok + 11, true); }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)