QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#659186#9487. Vivid Colorsucup-team1004#WA 3ms4528kbC++202.7kb2024-10-19 19:08:372024-10-19 19:08:37

Judging History

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

  • [2024-10-19 19:08:37]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:4528kb
  • [2024-10-19 19:08:37]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=2e3+5,M=N*120+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(263082);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
using cp=complex<db>;
int n,m,k;
int X[N],Y[N];
cp A[N];
db deg[N];
int rk[N],p[N];
ll sumx[N],sumy[N];
ll ans[N];
ll sq(ll x){return x*x;}
void chkmax(int x){
	ans[x]=max(ans[x],sq(2*sumx[x]-sumy[x])+sq(2*sumy[x]-sumx[x])+sq(sumx[x]+sumy[x]));
}
void chkswap(int x,db ti){
	ti+=1e-7;
	if(cos(ti)*(A[p[x]].real()-A[p[x+1]].real())+sin(ti)*(A[p[x]].imag()-A[p[x+1]].imag())<0){
		swap(p[x],p[x+1]);
		swap(rk[p[x]],rk[p[x+1]]);
		sumx[x]=sumx[x-1]+X[p[x]];
		sumy[x]=sumy[x-1]+Y[p[x]];
		chkmax(x);
		ti-=1e-7;
		if(x^1) chkswap(x-1,ti);
		if(x^n-1) chkswap(x+1,ti);
	}
}
ll mpow(ll x,int y=mod-2){ll ans=1;while(y) y&1&&(ans=ans*x%mod),y>>=1,x=x*x%mod;return ans;}
void Solve(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x,y,z;scanf("%d%d%d",&x,&y,&z);
		X[i]=y-x;Y[i]=z-x;
		A[i]=cp(sqrt(6)*X[i]-5.0/sqrt(6)*Y[i],sqrt(6-25.0/6)*Y[i]);
	}
	for(int i=1;i<=n;i++){
		deg[i]=atan2(A[i].imag(),A[i].real());
	}
	const db pi=acos(-1);
	vector<tuple<db,int,int> > Q;
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) if(fabs(deg[i]-deg[j])>eps){
		db w=atan2(A[i].imag()-A[j].imag(),A[j].real()-A[i].real());
		Q.emplace_back(w,i,j);
	}
	sort(all(Q));
	iota(p+1,p+n+1,1);
	sort(p+1,p+n+1,[](int x,int y){return A[x].real()>A[y].real();});
	for(int i=1;i<=n;i++) rk[p[i]]=i;
	for(int i=1;i<=n;i++) sumx[i]=sumx[i-1]+X[p[i]],sumy[i]=sumy[i-1]+Y[p[i]],chkmax(i);
	for(auto [w,x,y]:Q){
		if(rk[x]^n) chkswap(rk[x],w);
		if(rk[x]^1) chkswap(rk[x]-1,w);
		if(rk[y]^n) chkswap(rk[y],w);
		if(rk[y]^1) chkswap(rk[y]-1,w);
	}
	for(int i=1;i<=n;i++) gdb(ans[i]);
	for(int i=1;i<=n;i++) printf("%lld\n",ans[i]%mod*mpow(27*i*i)%mod);
}
int main(){
	int t=1;
	// scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 4528kb

input:

3
180 0 0
0 180 180
0 0 180

output:

7200
5400
800

result:

ok 3 tokens

Test #2:

score: 0
Accepted
time: 0ms
memory: 4472kb

input:

6
30594 32322 46262
63608 59020 98436
90150 32740 67209
82886 4627 54813
3112 67989 74995
60872 9967 9051

output:

715162883
838096208
930330061
405079896
880764907
526006962

result:

ok 6 tokens

Test #3:

score: -100
Wrong Answer
time: 3ms
memory: 4512kb

input:

144
41472 41434 41317
16965 16900 17440
65702 65688 65497
15829 15900 15359
186620 186555 186425
22130 22030 22145
22995 23022 23320
54430 54525 54770
145816 145739 146046
106008 106083 106073
84481 84531 84306
162468 162563 162313
144375 144342 144210
68596 68548 68201
124014 124100 123649
137878 1...

output:

665561664
166436731
579289313
55518246
226327601
523827415
697242492
166428961
72628719
361639205
499632513
554631323
305233223
309029649
197725655
853581515
286740033
873681088
443094922
905119354
107690174
499165266
848371940
176043988
31275150
39747201
676490856
965461580
788056873
59932649
12538...

result:

wrong answer 59th words differ - expected: '581174881', found: '280098852'