Submission #1734787
Source Code Expand
#include<vector> #include<string> #include<stdio.h> #include<algorithm> using namespace std; char in[410000]; string str[110000]; struct Trie{ int chi[26]; int sz; int flag; Trie(){ for(int i=0;i<26;i++)chi[i]=-1; sz=0;flag=0; } }; Trie pool[410000]; char qs[110000][30]; pair<int,int> p[110000]; int ans[110000]; int pl[30][30]; int main(){ int a;scanf("%d",&a); int ind=1; for(int i=0;i<a;i++){ scanf("%s",in); str[i]=in; int at=0; for(int j=0;in[j];j++){ if(pool[at].chi[in[j]-'a']==-1){ at=pool[at].chi[in[j]-'a']=ind; ind++; }else{ at=pool[at].chi[in[j]-'a']; } pool[at].sz++; } pool[at].flag=1; } int b;scanf("%d",&b); for(int i=0;i<b;i++){ int c;scanf("%d%s",&c,qs[i]); c--; p[i]=make_pair(c,i); } std::sort(p,p+b); int v=0; for(int i=0;i<a;i++){ for(int j=0;j<26;j++)for(int k=0;k<26;k++)pl[j][k]=0; int ad=0; int at=0; for(int j=0;j<str[i].size();j++){ if(pool[at].flag)ad++; for(int k=0;k<26;k++){ if(pool[at].chi[k]!=-1&&k!=str[i][j]-'a')pl[k][str[i][j]-'a']+=pool[pool[at].chi[k]].sz; } at=pool[at].chi[str[i][j]-'a']; } while(v<b&&p[v].first==i){ int t=p[v].second; int tmp=ad; for(int j=0;j<26;j++){ for(int k=j+1;k<26;k++){ tmp+=pl[qs[t][j]-'a'][qs[t][k]-'a']; } } ans[t]=tmp; v++; } } for(int i=0;i<b;i++)printf("%d\n",ans[i]+1); }
Submission Info
Submission Time | |
---|---|
Task | E - Lexicographical disorder |
User | tozangezan |
Language | C++14 (GCC 5.4.1) |
Score | 1100 |
Code Size | 1442 Byte |
Status | AC |
Exec Time | 233 ms |
Memory | 55552 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:23:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] int a;scanf("%d",&a); ^ ./Main.cpp:26:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s",in); ^ ./Main.cpp:40:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] int b;scanf("%d",&b); ^ ./Main.cpp:42:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] int c;scanf("%d%s",&c,qs[i]); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1100 / 1100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, s1.txt, s2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 211 ms | 55552 KB |
02.txt | AC | 233 ms | 55552 KB |
03.txt | AC | 219 ms | 55552 KB |
04.txt | AC | 230 ms | 55552 KB |
05.txt | AC | 173 ms | 52736 KB |
06.txt | AC | 132 ms | 51328 KB |
07.txt | AC | 125 ms | 51200 KB |
08.txt | AC | 123 ms | 51072 KB |
09.txt | AC | 120 ms | 51072 KB |
10.txt | AC | 118 ms | 51072 KB |
11.txt | AC | 138 ms | 52352 KB |
12.txt | AC | 151 ms | 52992 KB |
13.txt | AC | 161 ms | 53632 KB |
14.txt | AC | 128 ms | 51328 KB |
15.txt | AC | 119 ms | 51200 KB |
16.txt | AC | 116 ms | 51072 KB |
17.txt | AC | 111 ms | 51328 KB |
18.txt | AC | 115 ms | 51200 KB |
19.txt | AC | 115 ms | 51200 KB |
20.txt | AC | 119 ms | 51200 KB |
21.txt | AC | 119 ms | 51200 KB |
22.txt | AC | 119 ms | 51200 KB |
23.txt | AC | 147 ms | 52736 KB |
24.txt | AC | 139 ms | 52352 KB |
25.txt | AC | 148 ms | 52864 KB |
26.txt | AC | 113 ms | 51200 KB |
27.txt | AC | 117 ms | 51328 KB |
28.txt | AC | 119 ms | 51456 KB |
29.txt | AC | 116 ms | 51072 KB |
30.txt | AC | 132 ms | 51968 KB |
31.txt | AC | 119 ms | 51200 KB |
32.txt | AC | 116 ms | 51200 KB |
33.txt | AC | 115 ms | 51072 KB |
34.txt | AC | 116 ms | 51072 KB |
35.txt | AC | 116 ms | 51072 KB |
36.txt | AC | 219 ms | 55552 KB |
37.txt | AC | 114 ms | 51072 KB |
38.txt | AC | 114 ms | 51072 KB |
39.txt | AC | 22 ms | 46336 KB |
40.txt | AC | 22 ms | 46336 KB |
s1.txt | AC | 21 ms | 46336 KB |
s2.txt | AC | 21 ms | 46336 KB |