답안 #472783

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472783 2021-09-14T10:25:20 Z AbdoMo Lozinke (COCI17_lozinke) C++17
45 / 100
1000 ms 1484 KB
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define pb push_back
const int mod = 1e9+7;
using namespace std;
bool comp(string a,string b)
{
    if(a.size()==b.size())
    {
        return a<b;
    }
    return a.size()<b.size();
}
void solve(){
    int n;
    cin>>n;
    vector<string>v;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        v.pb(s);
    }
    sort(v.begin(),v.end(),comp);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(v[i].size()==v[j].size())
            {
                if(v[i]==v[j])
                ans+=2;
            }
            else
            {
                if(v[j].find(v[i])!=-1)
                {
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    /*

    */

}
int32_t main(){
	int t=1;
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //cin>>t;
	while(t--){solve();}
	return 0;
}

Compilation message

lozinke.cpp: In function 'void solve()':
lozinke.cpp:38:35: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |                 if(v[j].find(v[i])!=-1)
      |                    ~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 12 ms 376 KB Output is correct
6 Correct 29 ms 332 KB Output is correct
7 Correct 44 ms 332 KB Output is correct
8 Correct 29 ms 332 KB Output is correct
9 Execution timed out 1018 ms 848 KB Time limit exceeded
10 Correct 784 ms 848 KB Output is correct
11 Execution timed out 1086 ms 976 KB Time limit exceeded
12 Execution timed out 1080 ms 848 KB Time limit exceeded
13 Execution timed out 1095 ms 1484 KB Time limit exceeded
14 Execution timed out 1079 ms 1484 KB Time limit exceeded
15 Execution timed out 1089 ms 1484 KB Time limit exceeded
16 Execution timed out 1093 ms 1484 KB Time limit exceeded
17 Execution timed out 1004 ms 1484 KB Time limit exceeded
18 Execution timed out 1086 ms 1484 KB Time limit exceeded
19 Execution timed out 1082 ms 1484 KB Time limit exceeded
20 Execution timed out 1067 ms 1484 KB Time limit exceeded