Submission #3698487


Source Code Expand

#include<cstdio>
#define reg register
#define cmax(_a,_b) _a>_b?_a:_a=_b
char a[2005],b[2005];
int f[2005][2005],g[2005][2005];
int R()
{
	reg int x=0;reg bool f=0;reg char ch=getchar();
	for(;ch<48||ch>57;ch=getchar())if(ch=='-')f=1;
	for(;ch>=48&&ch<=57;ch=getchar())x=(x<<1)+(x<<3)+(ch^48);
	return f?-x:x;
}
int main()
{
	reg int n=R(),m=R(),i,j,ans=0;
	gets(a+1),gets(b+1);
	for(i=n+1;i;--i)
		for(j=m+1;j;--j) {
			if(a[i]=='O'&&a[i+1]=='I'&&b[j]=='O'&&b[j+1]=='I')cmax(g[i][j],g[i+2][j+2]+4);
			if(a[i]=='O'&&a[i+1]=='I')cmax(g[i][j],g[i+2][j]+2);
			if(b[j]=='O'&&b[j+1]=='I')cmax(g[i][j],g[i][j+2]+2);
			if(a[i]&&b[j]&&a[i]^b[j]) {
				cmax(g[i][j],g[i+1][j+1]+2);
				if(f[i+1][j+1]) cmax(f[i][j],f[i+1][j+1]+2);
			} 
			if(a[i]=='I')cmax(f[i][j],g[i+1][j]+1);
			if(b[j]=='I')cmax(f[i][j],g[i][j+1]+1);
			cmax(ans,f[i][j]);
		}
	return !printf("%d",ans);
}

Submission Info

Submission Time
Task A - IOI列車で行こう2
User luogu_bot1
Language C++ (GCC 5.4.1)
Score 0
Code Size 901 Byte
Status TLE
Exec Time 2103 ms
Memory 128 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16:2: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
  gets(a+1),gets(b+1);
  ^
In file included from /usr/include/c++/5/cstdio:42:0,
                 from ./Main.cpp:1:
/usr/include/stdio.h:638:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^
./Main.cpp:16:2: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
  gets(a+1),gets(b+1);
  ^
In file included from /usr/include/c++/5/cstdio:42:0,
                 from ./Main.cpp:1:
/usr/include/stdio.h:638:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^
./Main.cpp:16:10: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
  gets(a+1),gets(b+1);
          ^
In file included from /usr/include/c++/5/cstdio:42:0,
                 from ./Main.cpp:1:
/usr/include/stdio.h:638:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_depre...

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 0 / 30 0 / 70
Status
TLE × 3
TLE × 12
TLE × 21
Set Name Test Cases
Sample sample_1.txt, sample_2.txt, sample_3.txt
Subtask1 sample_1.txt, sample_2.txt, sample_3.txt, sub1_1.txt, sub1_2.txt, sub1_3.txt, sub1_4.txt, sub1_5.txt, sub1_6.txt, sub1_7.txt, sub1_8.txt, sub1_9.txt
Subtask2 sample_1.txt, sample_2.txt, sample_3.txt, sub1_1.txt, sub1_2.txt, sub1_3.txt, sub1_4.txt, sub1_5.txt, sub1_6.txt, sub1_7.txt, sub1_8.txt, sub1_9.txt, sub2_1.txt, sub2_2.txt, sub2_3.txt, sub2_4.txt, sub2_5.txt, sub2_6.txt, sub2_7.txt, sub2_8.txt, sub2_9.txt
Case Name Status Exec Time Memory
sample_1.txt TLE 2103 ms 128 KB
sample_2.txt TLE 2103 ms 128 KB
sample_3.txt TLE 2103 ms 128 KB
sub1_1.txt TLE 2103 ms 128 KB
sub1_2.txt TLE 2103 ms 128 KB
sub1_3.txt TLE 2103 ms 128 KB
sub1_4.txt TLE 2103 ms 128 KB
sub1_5.txt TLE 2103 ms 128 KB
sub1_6.txt TLE 2103 ms 128 KB
sub1_7.txt TLE 2103 ms 128 KB
sub1_8.txt TLE 2103 ms 128 KB
sub1_9.txt TLE 2103 ms 128 KB
sub2_1.txt TLE 2103 ms 128 KB
sub2_2.txt TLE 2103 ms 128 KB
sub2_3.txt TLE 2103 ms 128 KB
sub2_4.txt TLE 2103 ms 128 KB
sub2_5.txt TLE 2103 ms 128 KB
sub2_6.txt TLE 2103 ms 128 KB
sub2_7.txt TLE 2103 ms 128 KB
sub2_8.txt TLE 2103 ms 128 KB
sub2_9.txt TLE 2103 ms 128 KB