QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#656441#9487. Vivid Colorsucup-team5008#WA 0ms3572kbC++232.1kb2024-10-19 12:59:362024-10-19 12:59:37

Judging History

你现在查看的是最新测评结果

  • [2024-10-19 12:59:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3572kb
  • [2024-10-19 12:59:36]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define rep2(i,s,n) for(ll i = ll(s); i < ll(n); i++)
#define rrep(i,n) for(ll i = ll(n)-1; i >= 0; i--)
#define rrep2(i,n,t) for(ll i = ll(n)-1; i >= ll(t); i--)
#define all(a) a.begin(), a.end()
#define SZ(a) ll(a.size())
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vP = vector<P>;
using vvp = vector<vP>;

const ll inf = LLONG_MAX / 4;
bool chmin(auto &a, auto b) {return a > b ? a = b, 1 : 0; }
bool chmax(auto &a, auto b) {return a < b ? a = b, 1 : 0; }

const int mod = 998244353;

struct mint {
	ll x;
	mint(ll x = 0) : x((x%mod+mod)%mod) {}

	mint &operator+=(const mint &a) {
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint &operator*=(const mint &a) {
		(x *= a.x) %= mod;
		return *this;
	}

	mint pow(ll t) {
		mint res(1), a(*this);
		while(t) {
			if(t&1) res *= a;
			a *= a;
			t >>= 1;
		}
		return res;
	}
};

using vm = vector<mint>;
using vvm = vector<vm>;

int main() {
	cin.tie(0) -> sync_with_stdio(0);
	ll N; cin >> N;
	vl r(N), g(N), b(N);
	rep(i,N) cin >> r[i] >> g[i] >> b[i];
	vl ans(N, -1), idx(N, -1);
	auto dot = [&](ll i, ll j) {
		return r[i]*r[j]+g[i]*g[j]+b[i]*b[j];
	};


	auto dist = [&](ll R, ll G, ll B) {
		return R*R + G*G + B*B;
	};

	auto dist2 = [&](ll i) {
		return dist(r[i], g[i], b[i]);
	};

	rep(i,N) {
		vP data;
		rep(j,N) {
			if (i == j) continue;
			data.eb(dot(i,j), j);
		}
		sort(all(data));
		reverse(all(data));
		ll R = r[i], G = g[i], B = b[i];
		if (chmax(ans[0], dist(R, G, B))) idx[0] = i;
		rep(j,N-1) {
			ll k = data[j].second;
			R += r[k];
			G += g[k];
			B += b[k];
			if(chmax(ans[j+1], dist(R, G, B))) idx[j+1] = i;
		}
	}

	rep(K,N) {
		ll i = idx[K];
		vP data;
		rep(j,N) {
			if (i == j) continue;
			data.eb(dot(i,j), j);
		}
		sort(all(data));
		reverse(all(data));
		ll R = r[i], G = g[i], B = b[i];
		rep(j,K) {
			ll k = data[j].second;
			R += r[k];
			G += g[k];
			B += b[k];
		}
		mint ans = dist(R, G, B)%mod;
		ans *= mint(3*(K+1)*(K+1)*3%mod).pow(mod-2);
		cout << ans.x << endl;
	}

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3572kb

input:

3
180 0 0
0 180 180
0 0 180

output:

7200
4500
2400

result:

wrong answer 2nd words differ - expected: '5400', found: '4500'