Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- int T,length;
- string s;
- int counter = 0;
- cin >> T;
- cin.ignore(1,'\n');
- while(T--)
- {
- bool scarescrow[100] = {false};
- int field = 0;
- counter++;
- cin >> length;
- cin.ignore(1, '\n');
- getline(cin, s);
- for (int i = 0; i < length; ++i)
- {
- if(i == 0)
- {
- if(s[0] == '.')
- scarescrow[0] = true;
- }
- else if(i == 1)
- {
- if(s[0] == '.')
- {
- scarescrow[0] = false;
- scarescrow[1] = true;
- }
- else if(s[0] == '#' && s[1] == '.')
- scarescrow[1] = true;
- }
- else
- {
- if(scarescrow[i-1] == true)
- {
- if(scarescrow[i-2] == true)
- {
- scarescrow[i-1] = false;
- scarescrow[i] = true;
- }
- }
- else
- {
- if(s[i] == '.')
- scarescrow[i] = true;
- }
- }
- }
- for (int i = 0; i < length; ++i)
- {
- if(scarescrow[i] == true)
- field++;
- }
- cout << "Case " << counter << ": " << field << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement