Language: C++

＃define _CRT_SECURE_NO_WARNINGS
#define MATH_PI 3.14159265358979323846264338327950288419716939
#include <iostream>
#include <string.h>
using namespace std;
/* 入力省略用汎用マクロ・クラス */
#define CLIP(ptr, min, max) {if((min)<=(max)){if(ptr<(min)){ptr=(min);}if(ptr>(max)){ptr=(max);}}}
#define max(a, b) a > b ? a : b;
#define min(a, b) a > b ? b : a;
#define Sin(deg) sin((deg)*MATH_PI/180)
#define Cos(deg) cos((deg)*MATH_PI/180)
#define Tan(deg) tan((deg)*MATH_PI/180)
#define Rad(deg) ((deg)*MATH_PI/180)
#define _for(num) for(int i=0 ; i<num ; ++i)
#define _forj(num) for(int j=0 ; j<num ; ++j)
#define _fork(num) for(int k=0 ; k<num ; ++k)
#define _forl(num) for(int l=0 ; l<num ; ++l)
#define _forn(num) for(int n=0 ; n<num ; ++n)
#define __for(param, num) for(int param=0 ; param<num ; ++param)
/* paiza用の入力データ処理クラス */
class myStr{FILE *fp;int ptr,EOL_flag;int LocalFileOpen();int LocalFileClose();int LocalRead();int GetNextData(int *s, int *e);public:myStr();~myStr();string buf;int bufsize;int StreamRead();int GetNextAsInt();char *GetNextAsChar();int isEOL();void Print(string *str);void Print(string &str);};
#ifdef DEBUGMODE
#include "LocalFunc.h"
#else
myStr::myStr(){}myStr::~myStr(){}
int myStr::StreamRead(){getline(cin, buf);ptr = 0;bufsize = buf.size();EOL_flag = 0;return 1;}
void wait(){}
#endif
int myStr::GetNextData(int *s, int *e){int i;for (i = ptr; i<bufsize; ++i) {if (buf[i] != ' ') {*s = i;break;}}if (i >= bufsize) {EOL_flag = 1;return 0;}for (; i<bufsize; ++i) {if (buf[i] == ' ') {break;}}*e = i - 1;ptr = i;return 1;}int myStr::GetNextAsInt(){int s, e;int ret = GetNextData(&s, &e);if (isEOL()) return 0;return atoi(&buf[s]);}char *myStr::GetNextAsChar(){int s, e;int ret = GetNextData(&s, &e);if (isEOL()) return NULL;char *chr;chr = new char[e - s + 2];int i;for (i = s; i <= e; ++i) {chr[i - s] = buf[i];}chr[i - s] = 0;return chr;}int myStr::isEOL(){return EOL_flag;}void myStr::Print(string *str){cout << str->c_str() << endl;}void myStr::Print(string &str){Print(&str);}
/* 便利系関数 */
#define SORT_ORDER_ASCENDING 1
#define SORT_ORDER_DESCENDING 2
int GetMax(int *arr, int arr_size, int if_equal_get_first_flag = 1, int *ret_index = NULL) {if (arr_size <= 0) abort();int mx = arr[0], index = 0;for (int n = 1; n<arr_size; ++n) {if (if_equal_get_first_flag && arr[n] >  mx ||!if_equal_get_first_flag && arr[n] >= mx) {index = n;mx = arr[n];}}if (*ret_index) *ret_index = index;return mx;}int GetMin(int *arr, int arr_size, int if_equal_get_first_flag = 1, int *ret_index = NULL) {if (arr_size <= 0) abort();int mn = arr[0], index = 0;for (int n = 1; n<arr_size; ++n) {if (if_equal_get_first_flag && arr[n] <  mn ||!if_equal_get_first_flag && arr[n] <= mn) {index = n;mn = arr[n];}}if (*ret_index) *ret_index = index;	return mn;}template<typename T> void bSort(T *arr, int arr_size, int order, int *rule1 = NULL, int *rule2 = NULL, int *rule3 = NULL, int *rule4 = NULL) {int swapped, flag;T tmp;while (true) {swapped = 0;for (int n = 0; n<arr_size - 1; ++n) {flag = 0;if (order == SORT_ORDER_ASCENDING) {if (!rule1) {if (arr[n] > arr[n + 1]) flag = 1;}else {if (rule1[n] > rule1[n + 1]) flag = 1;if (rule1[n] == rule1[n + 1] && rule2) {if (rule2[n] > rule2[n + 1]) flag = 1;if (rule2[n] == rule2[n + 1] && rule3) {if (rule3[n] > rule3[n + 1]) flag = 1;if (rule3[n] == rule3[n + 1] && rule4) {if (rule4[n] > rule4[n + 1]) flag = 1;}}}}}if (order == SORT_ORDER_DESCENDING) {if (!rule1) {if (arr[n] < arr[n + 1]) flag = 1;}else {if (rule1[n] < rule1[n + 1]) flag = 1;if (rule1[n] == rule1[n + 1] && rule2) {if (rule2[n] < rule2[n + 1]) flag = 1;if (rule2[n] == rule2[n + 1] && rule3) {if (rule3[n] < rule3[n + 1]) flag = 1;if (rule3[n] == rule3[n + 1] && rule4) {if (rule4[n] < rule4[n + 1]) flag = 1;}}}}}if (flag) {tmp = arr[n]; arr[n] = arr[n + 1]; arr[n + 1] = tmp;if (rule1) swap(rule1[n], rule1[n + 1]);if (rule2) swap(rule2[n], rule2[n + 1]);if (rule3) swap(rule3[n], rule3[n + 1]);if (rule4) swap(rule4[n], rule4[n + 1]);swapped = 1;}}if (!swapped) break;}}int Within(int px, int py, int x1, int y1, int x2, int y2, int allow_on_border = 1) {if (allow_on_border) {if (px >= x1 && px <= x2 && py >= y1 && py <= y2) return 1; else return 0;}else {if (px > x1 && px < x2 && py > y1 && py < y2) return 1; else return 0;}}
inline int separate(char *c1, char *c2, char *c3, char *c4) {unsigned int i;char *src, *s1, *s2;int flag;src = (char *)malloc(strlen(c1) + 1);s1 = (char *)malloc(strlen(c2) + 1);s2 = (char *)malloc(strlen(c2) + 1);strcpy(src, c1);strcpy(s2, c2);c3[0] = 0;c4[0] = 0;flag = 0;for (i = 0; i<strlen(src); i++) {strncpy(s1, src + i, strlen(s2));s1[strlen(s2)] = 0;if (strcmp(s1, s2) == 0) {strcpy(c3, src);c3[i] = 0;strcpy(c4, src + i + strlen(s2));flag = 1;break;}}free(s1);free(s2);if (flag) {free(src);return 1;}else {strcpy(c3, src);free(src);c4[0] = 0;return 0;}}
/****************************************************************/
/* 問題固有のクラス
/****************************************************************/

/****************************************************************/
/* メイン処理部
/****************************************************************/
int main(void) {

	int a, b, c;
	char *cbuf = NULL, *cwork, cc[8192] = {0};
	int min_count, count;
	int len;
	myStr str;
	string s = "";

	int *count_s, *count_d;

	str.StreamRead();
	a = str.GetNextAsInt();
	str.StreamRead();
	cbuf = str.GetNextAsChar();

	len = strlen(cbuf);
	cwork = new char[len + 1];
	count_s = new int[len + 1];
	count_d = new int[len + 1];
	int cur_count_s = 0, cur_count_d = 0;

	int flag = 0;
	for(int i=len - 1; i >= 0 ; i--){
		count_s[i] = cur_count_s;
		count_d[i] = cur_count_d;
		if(flag == 0 && cbuf[i] == '.'){
			flag = 1;
			cur_count_d++;
		}
		else if(flag == 1){
			if(cbuf[i] == '.'){
				cur_count_d++;
			}else{
				cur_count_s++;
			}
		}

	}
	count_s[0] = cur_count_s;
	count_d[0] = cur_count_d;

	// ........
	count = 0;
	strcpy(cwork, cbuf);
	_for(len){
		if(cwork[i] == '#'){
			count++;
		}
	}
	min_count = count;

	// ########
	count = 0;
	strcpy(cwork, cbuf);
	_for(len) {
		if (cwork[i] == '.') {
			count++;
		}
	}
	min_count = min(count, min_count);

	// ....####
	int adj_count = 0;
	count = 99999999;
	strcpy(cwork, cbuf);
	_for(len) {
		if (cwork[i] == '#') {
			count = count_d[i] + adj_count;
			min_count  = min(count, min_count);
			adj_count++;
		}
	}

	cout << min_count << endl;

	wait();

	return 0;
}



Compiler output:
a.cc:1:1: error: '\U0000ff03define' does not name a type
    1 | ＃define _CRT_SECURE_NO_WARNINGS
      | ^~~~~~~~
In file included from /usr/include/c++/14/iosfwd:42,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:3:
/usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type
   68 |   typedef ptrdiff_t     streamsize; // Signed integral type
      |           ^~~~~~~~~
/usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
   40 | #include <cwchar> // For mbstate_t
  +++ |+#include <cstddef>
   41 | 
In file included from /usr/include/c++/14/bits/exception_ptr.h:38,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
  131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                          ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                                            ^~~~~~
In file included from /usr/include/wchar.h:35,
                 from /usr/include/c++/14/cwchar:44,
                 from /usr/include/c++/14/bits/postypes.h:40:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
  132 |   __attribute__((__externally_visible__));
      |                                         ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
  133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                          ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                                              ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
  134 |   __attribute__((__externally_visible__));
      |                                         ^
/usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared
  140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
      |                             ^~~
/usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared
  142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
      |                               ^~~
/usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function
  145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
      |                          ^~~~~~~~
/usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
      |                                            ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/new:145:52: error: expected primary-expression before 'const'
  145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
      |                                                    ^~~~~
/usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function
  147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
      |                          ^~~~~~~~
/usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
      |                                              ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/new:147:54: error: expected primary-expression before 'const'
  147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
      |                                                      ^~~~~
/usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function
  154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
      |                          ^~~~~~~~
/usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
      |                                            ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/new:154:68: error: expected primary-expression before ')' token
  154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
      |                                                                    ^
/usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive]
  155 |   __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
      |                                                                         ^
/usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function
  156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
      |                          ^~~~~~~~
/usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
      |                                            ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/new:156:68: error: expected primary-expression before ',' token
  156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
      |                                                                    ^
/usr/include/c++/14/new:156:70: error: expected primary-expression before 'const'
  156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
      |                                                                      ^~~~~
/usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function
  162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
      |                          ^~~~~~~~
/usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
      |                                              ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/new:162:70: error: expected primary-expression before ')' token
  162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
      |                                                                      ^
/usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive]
  163 |   __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
      |                                                                         ^
/usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function
  164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
      |                          ^~~~~~~~
/usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
      |                                              ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/new:164:70: error: expected primary-expression before ',' token
  164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
      |                                                                      ^
/usr/include/c++/14/new:164:72: error: expected primary-expression before 'const'
  164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
      |                                                                        ^~~~~
/usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared
  171 | void operator delete(void*, std::size_t, std::align_val_t)
      |                             ^~~
/usr/include/c++/14/new:173:31: error: 'std::size_t' has not been declared
  173 | void operator delete[](void*, std::size_t, std::align_val_t)
      |                               ^~~
/usr/include/c++/14/new:179:33: error: declaration of 'operator new' as non-function
  179 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
      |                                 ^~~~~~~~
/usr/include/c++/14/new:179:51: error: 'size_t' is not a member of 'std'; did you mean '