답안 #439293

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
439293 2021-06-29T13:43:25 Z Haidara 원형 문자열 (IZhO13_rowords) C++17
0 / 100
2000 ms 125888 KB
/* * * * * * * * * *
 *   ID: Haidara   *
 *   LANG: C++17   *
 *   PROB:         *
 * * * * * * * * * */
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define rep(i,x,n) for(int i=x;i<n;i++)
#define FOR(i,n) rep(i,0,n)
#define per(i,x,n) for(int i=x;i>n;i--)
#define ROF(i,x) for(int i=x;i>=0;i--)
#define v(i) vector< i >
#define p(i,j) pair< i , j >
#define pii pair<int,int>
#define m(i,j) map< i , j >
#define pq(i) priority_queue< i >
#define ff first
#define all(x) x.begin(),x.end()
#define ss second
#define pp push_back
using namespace std;
void SIO(string name="")
{
    if(name!="")
    {
        freopen((name+".in").c_str(),"r",stdin);
        freopen((name+".out").c_str(),"w",stdout);
    }
}
const int inf=1LL<<60LL;
const int mod=1e9+7;
const int maxn=4004;
signed main()
{
    SIO("");
    string sss,ll;
    cin>>sss>>ll;
    sss+=sss;
    ll+=ll;
    int n=sss.size(),m=ll.size();
    int ans=0;
    FOR(str1,n)
    FOR(str2,m)
    {
        string s=sss.substr(str1,n/2),l=ll.substr(str2/2);
        int dp[maxn][maxn]{};
        rep(i,1,n/2+1)
        rep(j,1,m/2+1)
        if(s[i-1]==l[j-1])
            dp[i][j]=dp[i-1][j-1]+1;
        else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        ans=max(ans,dp[n/2][m/2]);
    }
    cout<<ans;
}

Compilation message

rowords.cpp: In function 'void SIO(std::string)':
rowords.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         freopen((name+".in").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rowords.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen((name+".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2084 ms 125752 KB Time limit exceeded
2 Execution timed out 2032 ms 125672 KB Time limit exceeded
3 Execution timed out 2041 ms 125680 KB Time limit exceeded
4 Execution timed out 2090 ms 125636 KB Time limit exceeded
5 Execution timed out 2090 ms 125748 KB Time limit exceeded
6 Execution timed out 2105 ms 125704 KB Time limit exceeded
7 Execution timed out 2079 ms 125764 KB Time limit exceeded
8 Execution timed out 2095 ms 125884 KB Time limit exceeded
9 Execution timed out 2106 ms 125640 KB Time limit exceeded
10 Execution timed out 2097 ms 125640 KB Time limit exceeded
11 Execution timed out 2068 ms 125764 KB Time limit exceeded
12 Execution timed out 2092 ms 125772 KB Time limit exceeded
13 Execution timed out 2102 ms 125764 KB Time limit exceeded
14 Execution timed out 2100 ms 125768 KB Time limit exceeded
15 Execution timed out 2068 ms 125764 KB Time limit exceeded
16 Execution timed out 2074 ms 125764 KB Time limit exceeded
17 Execution timed out 2073 ms 125764 KB Time limit exceeded
18 Execution timed out 2102 ms 125688 KB Time limit exceeded
19 Execution timed out 2057 ms 125764 KB Time limit exceeded
20 Execution timed out 2054 ms 125724 KB Time limit exceeded
21 Execution timed out 2049 ms 125668 KB Time limit exceeded
22 Execution timed out 2059 ms 125888 KB Time limit exceeded
23 Execution timed out 2083 ms 125768 KB Time limit exceeded
24 Execution timed out 2085 ms 125820 KB Time limit exceeded
25 Execution timed out 2060 ms 125764 KB Time limit exceeded