Submission #52462354


Source Code Expand

// LUOGU_RID: 156145909
#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=50+5,M=2000+5,K=1000+5,mod=1e9+7,Mod=mod-1;const db eps=1e-8;const int INF=1e9+7;mt19937 rnd(181766);
#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;
int n,k,T,A[N][N];
ll dp[N][N][N][N];
void add(ll &x,ll y){(x+=y)>=mod&&(x-=mod);}
void Solve(){
	int i,j,h;scanf("%d%d%d",&n,&k,&T);
	for(i=1;i<=n;i++){
		for(j=1;j<=k;j++) scanf("%d",&A[i][j]);
		sort(A[i]+1,A[i]+k+1);
	}
	ll pw=1;
	for(i=n;i;i--){
		for(j=1;j<=k;j++) dp[i][i][j][0]=pw;pw=pw*k%mod;
		for(j=i+1;j<=n;j++) for(h=1;h<=k;h++){
			int pt=1;
			for(int p=0;p<=n-i;p++)if(dp[i+1][j][h][p]){
				while(pt<=k&&A[j][h]+p*T>A[i][pt]-T) pt++;
				add(dp[i][j][h][p+1],dp[i+1][j][h][p]*(pt-1)%mod);
				add(dp[i][j][h][p],dp[i+1][j][h][p]*(k-pt+1)%mod);
				// for(int q=1;q<=k;q++) add(dp[i][j][h][p+(A[j][h]+p*T>A[i][q]-T)],dp[i+1][j][h][p]);
			}
		} 
	}
	for(i=1;i<=n;i++){
		ll tot=0;for(j=1;j<=k;j++) for(h=0;h<=n;h++) tot+=dp[1][i][j][h]*h;
		printf("%lld\n",tot%mod);
	}
}
int main(){
	int t=1;
	// scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Submission Info

Submission Time
Task E - Strange Relation
User fangxintong
Language C++ 20 (gcc 12.2)
Score 1500
Code Size 1905 Byte
Status AC
Exec Time 28 ms
Memory 34156 KiB

Compile Error

Main.cpp: In function ‘void Solve()’:
Main.cpp:39:17: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
   39 |                 for(j=1;j<=k;j++) dp[i][i][j][0]=pw;pw=pw*k%mod;
      |                 ^~~
Main.cpp:39:53: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
   39 |                 for(j=1;j<=k;j++) dp[i][i][j][0]=pw;pw=pw*k%mod;
      |                                                     ^~
Main.cpp:32:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |         int i,j,h;scanf("%d%d%d",&n,&k,&T);
      |                   ~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:34:40: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |                 for(j=1;j<=k;j++) scanf("%d",&A[i][j]);
      |                                   ~~~~~^~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1500 / 1500
Status
AC × 3
AC × 37
Set Name Test Cases
Sample 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt
All 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt, 01-024.txt, 01-025.txt, 01-026.txt, 01-027.txt, 01-028.txt, 01-029.txt, 01-030.txt, 01-031.txt, 01-032.txt, 01-033.txt, 01-034.txt
Case Name Status Exec Time Memory
00-sample-001.txt AC 3 ms 3804 KiB
00-sample-002.txt AC 1 ms 3920 KiB
00-sample-003.txt AC 1 ms 4236 KiB
01-001.txt AC 1 ms 3948 KiB
01-002.txt AC 8 ms 13456 KiB
01-003.txt AC 5 ms 8868 KiB
01-004.txt AC 18 ms 24896 KiB
01-005.txt AC 9 ms 13744 KiB
01-006.txt AC 6 ms 10332 KiB
01-007.txt AC 11 ms 17316 KiB
01-008.txt AC 25 ms 34036 KiB
01-009.txt AC 27 ms 33972 KiB
01-010.txt AC 26 ms 33960 KiB
01-011.txt AC 27 ms 34016 KiB
01-012.txt AC 27 ms 33976 KiB
01-013.txt AC 25 ms 34044 KiB
01-014.txt AC 25 ms 34100 KiB
01-015.txt AC 26 ms 33972 KiB
01-016.txt AC 26 ms 34112 KiB
01-017.txt AC 27 ms 34032 KiB
01-018.txt AC 27 ms 33980 KiB
01-019.txt AC 27 ms 33976 KiB
01-020.txt AC 27 ms 33924 KiB
01-021.txt AC 27 ms 33972 KiB
01-022.txt AC 27 ms 34104 KiB
01-023.txt AC 27 ms 34040 KiB
01-024.txt AC 27 ms 34156 KiB
01-025.txt AC 28 ms 34112 KiB
01-026.txt AC 27 ms 33968 KiB
01-027.txt AC 28 ms 34020 KiB
01-028.txt AC 27 ms 34108 KiB
01-029.txt AC 27 ms 34036 KiB
01-030.txt AC 28 ms 34036 KiB
01-031.txt AC 27 ms 34108 KiB
01-032.txt AC 27 ms 33972 KiB
01-033.txt AC 28 ms 34116 KiB
01-034.txt AC 27 ms 33972 KiB