Submission #2408831
Source Code Expand
#include <cstdio> #include <cstring> using namespace std; int main() { int i, j; int n; char S[55][55]; int num_alphabet[55][26] = {}; int least_alphabet[26]; for(i = 0; i < 26; i++) { least_alphabet[i] = 100; } scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", S[i]); } for (i = 0; i < n; i++) { for (j = 0; j < strlen(S[i]); j++) { int d = (int)S[i][j] - 97; num_alphabet[i][d] += 1; } } for (j = 0; j < 26; j++) { for (i = 0; i < n; i++) { if (least_alphabet[j] > num_alphabet[i][j]) { least_alphabet[j] = num_alphabet[i][j]; } } } //for (i = 0; i < 26; i++) { // printf("%d ", least_alphabet[i]); //} char ans[55]; int p = 0; for (i = 0; i < 26; i++) { for (j = 0; j < least_alphabet[i]; j++) { ans[p+j] = (char)(97+i); } p += least_alphabet[i]; } for (i = 0; i < p; i++) { printf("%c", ans[i]); } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Dubious Document |
User | sauce |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 988 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 128 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:15:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:17:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s", S[i]); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt |
All | 0_000.txt, 0_001.txt, dec_half.txt, hand.txt, max.txt, max_10.txt, max_5.txt, maxx.txt, rnd.txt, single.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 0 ms | 128 KB |
0_001.txt | AC | 1 ms | 128 KB |
dec_half.txt | AC | 1 ms | 128 KB |
hand.txt | AC | 1 ms | 128 KB |
max.txt | AC | 1 ms | 128 KB |
max_10.txt | AC | 1 ms | 128 KB |
max_5.txt | AC | 1 ms | 128 KB |
maxx.txt | AC | 1 ms | 128 KB |
rnd.txt | AC | 1 ms | 128 KB |
single.txt | AC | 0 ms | 128 KB |