제출 #1271352

#제출 시각아이디문제언어결과실행 시간메모리
1271352SmuggingSpunLozinke (COCI17_lozinke)C++20
0 / 100
195 ms17120 KiB
#include<bits/stdc++.h> #define taskname "C" using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } int n, ans = 0; cin >> n; vector<string>s; map<string, int>cnt, s_cnt; for(int i = 0; i < n; i++){ string x; cin >> x; if(cnt[x]++ == 0){ s.emplace_back(x); } } sort(s.begin(), s.end(), [&] (string i, string j){ return i.size() > j.size(); }); for(string& x : s){ int cx = cnt[x]; ans += s_cnt[x]; map<string, bool>app; for(int i = 0; i < x.size(); i++){ string t = ""; for(int j = i; j < x.size(); j++){ if(!app[t += x[j]]){ app[t] = true; s_cnt[t] += cx; } } } } for(auto it = cnt.begin(); it != cnt.end(); it++){ ans += (it->second * (it->second - 1)) >> 1; } cout << ans; }

컴파일 시 표준 에러 (stderr) 메시지

lozinke.cpp: In function 'int main()':
lozinke.cpp:7:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...