結果

問題 No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
ユーザー kotatsugamekotatsugame
提出日時 2020-05-29 22:10:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 923 bytes
コンパイル時間 947 ms
コンパイル使用メモリ 85,588 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 22:47:14
合計ジャッジ時間 3,256 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 145 ms
5,376 KB
testcase_12 AC 112 ms
5,376 KB
testcase_13 AC 160 ms
5,376 KB
testcase_14 AC 84 ms
5,376 KB
testcase_15 AC 42 ms
5,376 KB
testcase_16 AC 48 ms
5,376 KB
testcase_17 AC 9 ms
5,376 KB
testcase_18 AC 103 ms
5,376 KB
testcase_19 AC 92 ms
5,376 KB
testcase_20 AC 76 ms
5,376 KB
testcase_21 AC 170 ms
5,376 KB
testcase_22 AC 171 ms
5,376 KB
testcase_23 AC 169 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
const long mod=998244353;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
int N,Q;
long dp[6060];
int ans[5050];
int L[5050],R[5050],P[5050];
main()
{
	cin>>N>>Q;
	map<int,int>mp;
	long T=1;
	for(int i=0;i<N;i++)
	{
		int A;cin>>A;mp[A]++;
		T=T*A%mod;
	}
	for(int i=0;i<Q;i++)
	{
		cin>>L[i]>>R[i]>>P[i];
	}
	vector<pair<int,int> >X(mp.begin(),mp.end());
	dp[0]=T;
	for(int i=X.size();i--;)
	{
		long A=X[i].first;
		long invA=power(A,mod-2);
		for(int j=0;j<X[i].second;j++)
		{
			for(int k=N;k>=0;k--)
			{
				(dp[k+1]+=dp[k]*invA)%=mod;
				dp[k]=dp[k]*(A-1)%mod*invA%mod;
			}
		}
		for(int j=0;j<Q;j++)
		{
			int r=min(R[j],(int)A);
			int l=max(L[j],i==0?1:X[i-1].first+1);
			if(l<=r)
			{
				if((r-l+1)%2==1)ans[j]^=dp[P[j]];
				R[j]=l-1;
			}
		}
	}
	for(int i=0;i<Q;i++)cout<<ans[i]<<endl;
}
0