답안 #818897

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
818897 2023-08-10T07:14:19 Z vjudge1 Growing Vegetable is Fun 3 (JOI19_ho_t3) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define el cout<<endl;
#define fr(n,m) for(int i=n;i<m;i++)
#define frj(n,m) for(int j=n;j<m;j++)
#define frl(n,m) for(int l=n;l<m;l++)
#define frd(n,m) for(int d=n;d<m;d++)
#define ff for(int i=0;i<n;i++)
#define mii map<int,int>
#define mci map<char,int>
#define vi vector<int>
#define vc vector<char>
#define mivi map<int,vi>
#define pb push_back
#define ext cout<<-1;return;
#define inf 1e18
#define sz size()
#define fi first
#define se second
const int mod = 1e9 + 7;
// const int mod=998
int i = 0, j = 0, k = 0, l = 0, h = 0, w = 0, a = 0, b = 0, c = 0, d = 0, n = 0, m = 0;
int num = 0, ans = 0, sum = 0, mi = inf, ma = 0;
string s, p, st;
const int N = 1e3 + 5;
void solve() {
	cin >> n >> s;
	vi v(n);
	mii mp;
	ff{
		if (s[i] == s[0]) {
			mp[0]++;
		}
		else mp[1]++;
	}
	a = n / 2; b = n - a;
	// if (mp.sz == 2) {
	if ((mp[0] == a && mp[1] == b) || (mp[1] == a && mp[0] == b)) {
		int x = 0, num = 0;
		ff{
			if (s[i] == s[0]) {
				num += x;	
				x--;
			}
			else{
				x++;
			}
		}
		mi = abs(num);
		x = 0, num = 0;
		ff{
			if (s[i] != s[0]) {
				num += x;
				x--;
			}
			else{
				x++;
			}
		}
		mi = min(mi, abs(num));
		cout << mi;
	}
	else ext;
	// }
	// else {

	// }
}
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int T = 1;
	// cin >> T;
	while (T--) {
		cout << fixed << setprecision(12); solve();
		el;
	} return 0;
}

Compilation message

joi2019_ho_t3.cpp: In function 'void solve()':
joi2019_ho_t3.cpp:16:13: warning: macro expands to multiple statements [-Wmultistatement-macros]
   16 | #define ext cout<<-1;return;
      |             ^~~~
joi2019_ho_t3.cpp:64:7: note: in expansion of macro 'ext'
   64 |  else ext;
      |       ^~~
joi2019_ho_t3.cpp:64:2: note: some parts of macro expansion are not guarded by this 'else' clause
   64 |  else ext;
      |  ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -