|
#define MAX_LEN 4 |
|
|
|
////////////////////////// |
|
#define SET 3 |
|
#define C 10 |
|
|
|
#include<cstdio> |
|
#include<algorithm> |
|
#include<stack> |
|
#include<queue> |
|
#include<vector> |
|
#include<string> |
|
#include<string.h> |
|
#include<cstdlib> |
|
#include<ctime> |
|
#include<cmath> |
|
#include<map> |
|
#include<set> |
|
#include<iostream> |
|
#include<sstream> |
|
#include<cctype> |
|
#define fi first |
|
#define se second |
|
#define rep(i,n) for(int i = 0; i < n; i++) |
|
#define rrep(i,n) for(int i = 1; i <= n; i++) |
|
#define drep(i,n) for(int i = n-1; i >= 0; i--) |
|
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next) |
|
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++) |
|
#define rng(a) a.begin(),a.end() |
|
#define maxs(x,y) x = max(x,y) |
|
#define mins(x,y) x = min(x,y) |
|
#define pb push_back |
|
#define sz(x) (int)(x).size() |
|
#define pcnt __builtin_popcount |
|
#define snuke srand((unsigned)clock()+(unsigned)time(NULL)) |
|
using namespace std; |
|
typedef long long int ll; |
|
typedef pair<int,int> P; |
|
typedef vector<int> vi; |
|
|
|
// Time |
|
#include<sys/time.h> |
|
ll getTime() { |
|
struct timeval tv; |
|
gettimeofday(&tv, NULL); |
|
ll result = tv.tv_sec * 1000LL + tv.tv_usec / 1000LL; |
|
return result; |
|
} |
|
ll start_time, time_limit; |
|
void setTime(){ start_time = getTime();} |
|
ll nowTime(){ return getTime() - start_time;} |
|
bool timeup(){ return nowTime() > time_limit;} |
|
// |
|
|
|
const int MX = 100005, INF = 1000010000; |
|
const ll LINF = 1000000000000000000ll; |
|
const double eps = 1e-10; |
|
const int dx[] = {-1,0,1,0}, dy[] = {0,-1,0,1}; //<^>v |
|
|
|
vector<string> d; |
|
|
|
inline void add(string s, char c){ |
|
d[c-'A'] = s; |
|
} |
|
void init(){ |
|
d.resize(26); |
|
add(".",'E'); |
|
add("-",'T'); |
|
add("..",'I'); |
|
add(".-",'A'); |
|
add("-.",'N'); |
|
add("--",'M'); |
|
add("...",'S'); |
|
add("..-",'U'); |
|
add(".-.",'R'); |
|
add(".--",'W'); |
|
add("-..",'D'); |
|
add("-.-",'K'); |
|
add("--.",'G'); |
|
add("---",'O'); |
|
add("....",'H'); |
|
add("...-",'V'); |
|
add("..-.",'F'); |
|
add(".-..",'L'); |
|
add(".--.",'P'); |
|
add(".---",'J'); |
|
add("-...",'B'); |
|
add("-..-",'X'); |
|
add("-.-.",'C'); |
|
add("-.--",'Y'); |
|
add("--..",'Z'); |
|
add("--.-",'Q'); |
|
} |
|
char fix(char c){ |
|
if(c >= 'A' && c <= 'Z') return c; |
|
return c+'A'-'a'; |
|
} |
|
|
|
int main(){ |
|
snuke; |
|
init(); |
|
|
|
vi x(26); |
|
rep(i,26) x[i] = i; |
|
//random_shuffle(rng(x)); |
|
rep(i,1000) swap(x[i%26],x[rand()%26]); |
|
int point = 0, tot = 0; |
|
cout << "0 : sign - alp training" << endl; |
|
cout << "1 : alp - sign training" << endl; |
|
cout << "2 : sign - alp test" << endl; |
|
cout << "3 : alp - sign test" << endl; |
|
int mode; |
|
cin >> mode; |
|
setTime(); |
|
if(mode == 0){ |
|
rep(i,26){ |
|
char c = x[i]+'A', r; |
|
string s = d[x[i]]; |
|
if(sz(s) > MAX_LEN) continue; |
|
tot++; |
|
cout << s << " : "; fflush(stdout); |
|
cin >> r; r = fix(r); |
|
if(r == c){ |
|
cout << "correct!" << endl; |
|
point++; |
|
} else { |
|
cout << "wrong... : " << c << " "; fflush(stdout); |
|
while(1){ |
|
cin >> r; r = fix(r); |
|
if(r == c) break; |
|
} |
|
} |
|
} |
|
cout << endl << "Score : " << point << " / " << tot << endl; |
|
cout << "Time : "; |
|
printf("%.3f", nowTime()*0.001); |
|
cout << "s" << endl; |
|
} else if(mode == 1) { |
|
rep(i,26){ |
|
char c = x[i]+'A'; |
|
string s = d[x[i]], r; |
|
if(sz(s) > MAX_LEN) continue; |
|
tot++; |
|
cout << c << " : "; fflush(stdout); |
|
cin >> r; |
|
if(r == s){ |
|
cout << "correct!" << endl; |
|
point++; |
|
} else { |
|
cout << "wrong... : " << s << " "; fflush(stdout); |
|
while(1){ |
|
cin >> r; |
|
if(r == s) break; |
|
} |
|
} |
|
} |
|
cout << endl << "Score : " << point << " / " << tot << endl; |
|
cout << "Time : "; |
|
printf("%.3f", nowTime()*0.001); |
|
cout << "s" << endl; |
|
} else if(mode == 2) { |
|
rep(si,SET){ |
|
vi y; |
|
rep(ci,C){ |
|
int i = rand()%26; |
|
cout << d[i] << " "; |
|
y.pb(i); |
|
} |
|
cout << endl; |
|
string s, ns; |
|
while(sz(s) < C){ |
|
cin >> ns; |
|
s += ns; |
|
} |
|
rep(ci,C) if(y[ci] == fix(s[ci])-'A') point++; |
|
} |
|
tot = SET*C; |
|
printf("Correct : %d / %d\n",point,tot); |
|
int tm = nowTime(); |
|
printf("Time : %.3fs + %d * 3s = %.3fs\n", tm*0.001, tot-point, (tot-point)*3+tm*0.001); |
|
} else if(mode == 3) { |
|
rep(si,SET){ |
|
vi y; |
|
string s; |
|
rep(ci,C){ |
|
int i = rand()%26; |
|
s += i+'a'; |
|
y.pb(i); |
|
} |
|
cout << s << endl; |
|
rep(ci,C){ |
|
cin >> s; |
|
if(s == d[y[ci]]) point++; |
|
} |
|
} |
|
tot = SET*C; |
|
printf("Correct : %d / %d\n",point,tot); |
|
int tm = nowTime(); |
|
printf("Time : %.3fs + %d * 3s = %.3fs\n", tm*0.001, tot-point, (tot-point)*3+tm*0.001); |
|
} |
|
return 0; |
|
} |
|
|
|
|
|
|
|
|
|
|