답안 #677607

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
677607 2023-01-03T22:20:58 Z Mariabf Lozinke (COCI17_lozinke) C++17
40 / 100
1000 ms 1108 KB
#include<bits/stdc++.h>
using namespace std;
bool comp(string a, string b){
    for(int i=0; i<a.size(); i++){
        for(int j=0; j<b.size(); j++){
            if(a[i+j]!=b[j])break;
            if(j==b.size()-1)return true;
        }
    }
    return false;
}
int main(){
    int n;
    cin>>n;
    vector<string>v(n);
    for(int i=0; i<n; i++){
        cin>>v[i];
    }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()){
                ans+=comp(v[i], v[j]);
            }
            else if(v[i].size()==v[j].size()){
                ans+=2*comp(v[j], v[i]);
            }
            else{
                ans+=comp(v[j], v[i]);
            }
        }
    }cout<<ans;
}

Compilation message

lozinke.cpp: In function 'bool comp(std::string, std::string)':
lozinke.cpp:4:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 |     for(int i=0; i<a.size(); i++){
      |                  ~^~~~~~~~~
lozinke.cpp:5:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 |         for(int j=0; j<b.size(); j++){
      |                      ~^~~~~~~~~
lozinke.cpp:7:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |             if(j==b.size()-1)return true;
      |                ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 5 ms 212 KB Output is correct
5 Correct 27 ms 332 KB Output is correct
6 Correct 72 ms 340 KB Output is correct
7 Correct 87 ms 340 KB Output is correct
8 Correct 73 ms 356 KB Output is correct
9 Execution timed out 1095 ms 596 KB Time limit exceeded
10 Execution timed out 1093 ms 596 KB Time limit exceeded
11 Execution timed out 1096 ms 852 KB Time limit exceeded
12 Execution timed out 1095 ms 852 KB Time limit exceeded
13 Execution timed out 1091 ms 1108 KB Time limit exceeded
14 Execution timed out 1096 ms 980 KB Time limit exceeded
15 Execution timed out 1091 ms 980 KB Time limit exceeded
16 Execution timed out 1097 ms 1108 KB Time limit exceeded
17 Execution timed out 1094 ms 1108 KB Time limit exceeded
18 Execution timed out 1091 ms 1108 KB Time limit exceeded
19 Execution timed out 1089 ms 980 KB Time limit exceeded
20 Execution timed out 1085 ms 980 KB Time limit exceeded