Skip to content

Instantly share code, notes, and snippets.

@yuuki
Created May 24, 2012 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuuki/2784346 to your computer and use it in GitHub Desktop.
Save yuuki/2784346 to your computer and use it in GitHub Desktop.
SRM Div2-145 200score
// {{{ Boilerplate Code <--------------------------------------------------
//
// vim:filetype=cpp foldmethod=marker foldmarker={{{,}}}
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N) FOR(I,0,N)
#define ALL(A) (A).begin(), (A).end()
using namespace std;
// }}}
class ImageDithering
{
public:
int count(string dithered, vector<string> screen)
{
int sum = 0;
for (vector<string>::iterator str = screen.begin(); str != screen.end(); ++str) {
for (string::iterator pos = str->begin(); pos != str->end(); ++pos) {
for (string::iterator d = dithered.begin(); d != dithered.end(); ++d) {
if (*pos != *d) continue;
++sum;
}
}
}
return sum;
}
};
int main() {
ImageDithering image;
string screen1[] = {"AAAAAAAA",
"ABWBWBWA",
"AWBWBWBA",
"ABWBWBWA",
"AWBWBWBA",
"AAAAAAAA"};
vector<string> v(6);
v.assign(screen1, screen1 + 6);
cout << image.count("BW", v) << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment