# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28520 | 흐훗흐흐훗핫 (#68) | Play Onwards (FXCUP2_onward) | C++98 | 0 ms | 2032 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <string>
using namespace std;
string tmp[333];
int dp[333];
int main(void)
{
int n,m;
cin >> n >> m;
for(int e=0;e<n;e++) cin >> tmp[e];
for(int e=0;e<n;e++)
{
if(dp[e]==0)
{
dp[e]=1;
}
for(int p=e+1;p<n;p++)
{
int mm=0,qq=0,rr=0;
for(int q=0;q<tmp[e].size();q++)
{
for(int r=0;r<tmp[p].size();r++)
{
if(tmp[e][q]==tmp[p][r])
{
rr=0;
qq=0;
for(int ee=r;ee<tmp[p].size()&&q+qq<tmp[e].size();ee++,qq++)
{
if(tmp[e][q+qq]==tmp[p][ee])
{
rr++;
mm=max(mm,rr);
}
else
{
break;
}
}
}
}
}
if(mm>=m)
{
if(dp[e]==1)
{
if(dp[p]==1)
{
cout << "No";
return 0;
}
else
{
dp[p]=2;
}
}
if(dp[e]==2)
{
if(dp[p]==2)
{
cout << "No";
return 0;
}
else
{
dp[p]=1;
}
}
}
else
{
if(dp[e]==1)
{
if(dp[p]==2)
{
cout << "No";
return 0;
}
else
{
dp[p]=1;
}
}
if(dp[e]==2)
{
if(dp[p]==1)
{
cout << "No";
return 0;
}
else
{
dp[p]=2;
}
}
}
}
}
int pp=0;
for(int e=0;e<n;e++) if(dp[e]==1) pp++;
if(pp==0) dp[0]=1;
if(pp==n) dp[0]=2;
cout << "Yes\n";
for(int e=0;e<n;e++) cout << dp[e] << "\n";
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |