답안 #255923

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
255923 2020-08-02T05:51:02 Z 임성재(#5031) Mixture (BOI20_mixture) C++17
0 / 100
3 ms 384 KB
#include<bits/stdc++.h>  
using namespace std;  
  
#define fast ios::sync_with_stdio(false);cin.tie(NULL)  
#define fi first  
#define se second  
#define all(v) (v).begin(),(v).end()  
#define pb push_back  
#define eb emplace_back
#define pre(a) cout<<fixed; cout.precision(a)
#define mp make_pair
  
typedef long long ll;  
typedef pair<int,int> pii;  
typedef pair<ll,ll> pll;  
const long long INF = 1e18;
const int inf = 1e9;

int n, q;
ll s[100010], p[100010], g[100010];
ll a[100010], b[100010];
ll A[4][5];
ll cnt[4];

void sw(int i, int j) {
	for(int k=1; k<=4; k++) {
		swap(A[i][k], A[j][k]);
	}
}

void add(int i, int j, int m) {
	for(int k=1; k<=4; k++) {
		A[i][k] += A[j][k] * m;
	}
}

void mul(int i, int j) {
	for(int k=1; k<=4; k++) {
		A[i][k] *= j;
	}
}

void REF() {
	int x = 1, y = 1;
	
	while (y <= 3) {
		for(int i=x; i<=3; i++) {
			if(A[i][y] != 0) sw(x, i);
		}

		if(A[x][y] == 0) {
			y++;
		}
		else {
			for(int i=1; i<=3; i++) {
				if(i == x) continue;
				mul(i, A[x][y]);
				add(i, x, - A[i][y] / A[x][y]);
			}

			x++, y++;
		}
	}
}

bool f(int i, int j, int k) {
	A[1][1] = s[i];
	A[2][1] = p[i];
	A[3][1] = g[i];
	
	A[1][2] = s[j];
	A[2][2] = p[j];
	A[3][2] = g[j];
	
	A[1][3] = s[k];
	A[2][3] = p[k];
	A[3][3] = g[k];

	A[1][4] = s[0];
	A[2][4] = p[0];
	A[3][4] = g[0];

	REF();

	for(int i=1; i<=3; i++) {
		for(int j=1; j<=4; j++) {
			if(j == 4 && A[i][j] != 0) return false;

			if(A[i][j] != 0) {
				if(A[i][j] * A[i][4] < 0) return false;
				break;
			}
		}
	}

	return true;
}

int main() {
	fast;

	cin >> s[0] >> p[0] >> g[0];

	cin >> q;

	while(q--) {
		string t;
		cin >> t;

		if(t == "A") {
			n++;
			cin >> s[n] >> p[n] >> g[n];

			if(f(n, n, n)) cnt[1]++;

			for(int i=1; i<n; i++) {
				if(f(i, n, n)) cnt[2]++;
			}

			for(int i=1; i<n; i++) {
				for(int j=1; j<i; j++) {
					if(f(j, i, n)) cnt[3]++;
				}
			}
		}
		else {
			int k;
			cin >> k;

			if(f(k, k, k)) cnt[1]--;

			for(int i=1; i<=n; i++) {
				if(i == k) continue;
				if(f(i, k, k)) cnt[2]--;
			}

			for(int i=1; i<=n; i++) {
				for(int j=1; j<i; j++) {
					if(i == k || j == k) continue;
					if(f(j, i, k)) cnt[3]--;
				}
			}

			s[k] = p[k] = g[k] = 0;

			if(f(k, k, k)) cnt[1]++;

			for(int i=1; i<=n; i++) {
				if(i == k) continue;
				if(f(i, k, k)) cnt[2]++;
			}

			for(int i=1; i<=n; i++) {
				for(int j=1; j<i; j++) {
					if(i == k || j == k) continue;
					if(f(j, i, k)) cnt[3]++;
				}
			}
		}

		if(cnt[1] > 0) cout << "1\n";
		else if(cnt[2] > 0) cout << "2\n";
		else if(cnt[3] > 0) cout << "3\n";
		else cout << "0\n";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 0 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 0 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 0 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Incorrect 0 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -