EOF 대신 '\n'을 사용하면 시간초과가 난다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cstring> | |
using namespace std; | |
int cnt[26]; | |
int main(void){ | |
char ch; | |
int idx =0; | |
memset(cnt,-1,sizeof(int)*26); | |
int temp = 0; | |
while ((ch = getchar()) != EOF){ | |
int idx = ch - 'a'; | |
if (cnt[idx] == -1) | |
cnt[idx] = temp; | |
temp++; | |
} | |
for (int i=0;i<26;i++){ | |
printf("%d ",cnt[i]); | |
} | |
} |
댓글
댓글 쓰기