Submission #45622165


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;
ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+
(x<<3)+(ch^48);ch=getchar();}return x*f;}
#define Z(x) (x)*(x)
#define pb push_back
//#define M
//#define mo
#define M 110
int n, m, i, j, k, T, ans=1e9, b[10];
char s[4][M]; 

int find(int k, int t) {
	for(; t<=5*m; ++t) 
		if(s[k][t%m]==i) break; 
	return t; 
}

void dfs(int x, int t) {
	if(x>3) {
		ans=min(ans, t-1); 
		return ; 
	}
	for(int k=1; k<=3; ++k) 
		if(!b[k])  {
			
			int tt=find(k, t); 
			if(tt>=5*m) continue; 
			b[k]=1; 
			dfs(x+1, tt+1); 
			b[k]=0; 
		}
}

signed main()
{
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
//	srand(time(NULL));
//	T=read();
//	while(T--) {
//
//	}
	n=3; m=read(); 
	for(i=1; i<=n; ++i) {
		scanf("%s", s[i]); 
	}
	for(i='0'; i<='9'; ++i) {
		dfs(1, 0); 
	}
	if(ans>=5*m) printf("-1"); 
	else printf("%lld", ans); 
	return 0;
}

Submission Info

Submission Time
Task C - Slot Strategy 2 (Easy)
User zhangtingxi
Language C++ 20 (gcc 12.2)
Score 300
Code Size 1067 Byte
Status AC
Exec Time 2 ms
Memory 3872 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:49:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   49 |                 scanf("%s", s[i]);
      |                 ~~~~~^~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 26
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 1 ms 3628 KiB
random_02.txt AC 1 ms 3600 KiB
random_03.txt AC 1 ms 3740 KiB
random_04.txt AC 1 ms 3656 KiB
random_05.txt AC 1 ms 3852 KiB
random_06.txt AC 1 ms 3840 KiB
random_07.txt AC 2 ms 3872 KiB
random_08.txt AC 1 ms 3604 KiB
random_09.txt AC 1 ms 3788 KiB
random_10.txt AC 1 ms 3832 KiB
random_11.txt AC 1 ms 3560 KiB
random_12.txt AC 1 ms 3600 KiB
random_13.txt AC 1 ms 3720 KiB
random_14.txt AC 1 ms 3632 KiB
random_15.txt AC 1 ms 3684 KiB
random_16.txt AC 1 ms 3648 KiB
random_17.txt AC 1 ms 3740 KiB
random_18.txt AC 1 ms 3824 KiB
random_19.txt AC 1 ms 3824 KiB
random_20.txt AC 1 ms 3672 KiB
random_21.txt AC 1 ms 3604 KiB
random_22.txt AC 1 ms 3840 KiB
random_23.txt AC 1 ms 3640 KiB
sample_01.txt AC 1 ms 3672 KiB
sample_02.txt AC 1 ms 3628 KiB
sample_03.txt AC 1 ms 3580 KiB