#include #include "unicode_names.h" using namespace std; enum validation:int{ CORRECT = 42, WRONG_ANSWER = 43, JUDGE_ERROR = 1, }; enum answer:int{ INVALID = -1, IMPOSSIBLE = -2, }; enum exercise:int{ REST = 1, LEG = 2, ARM = 3 }; namespace bjoern{ // Copyright (c) 2008-2009 Bjoern Hoehrmann // See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details. static const uint8_t utf8d[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 00..1f 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 20..3f 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 40..5f 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 60..7f 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, // 80..9f 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, // a0..bf 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // c0..df 0xa,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x4,0x3,0x3, // e0..ef 0xb,0x6,0x6,0x6,0x5,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8, // f0..ff 0x0,0x1,0x2,0x3,0x5,0x8,0x7,0x1,0x1,0x1,0x4,0x6,0x1,0x1,0x1,0x1, // s0..s0 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,1, // s1..s2 1,2,1,1,1,1,1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1, // s3..s4 1,2,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,3,1,1,1,1,1,1, // s5..s6 1,3,1,1,1,1,1,3,1,3,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // s7..s8 }; uint32_t decode(uint32_t* state, uint32_t* codep, uint32_t byte) { uint32_t type = utf8d[byte]; *codep = (*state != 0) ? (byte & 0x3fu) | (*codep << 6) : (0xff >> type) & (byte); *state = utf8d[256 + *state*16 + type]; return *state; } } bool is_control_code(uint32_t c){ return 0x0000<=c and c<=0x001f or 0x007f<=c and c<=0x009f; } bool is_ascii_printable_char(uint32_t c){ return 0x20<=c and c<=0x7e; } bool is_fitzpatrick_type(uint32_t c){ return 0x1f3fb<=c and c<=0x1f3ff; } int main(int argc, char** argv) { ifstream data(argv[1]); wifstream jury(argv[2]); //istream &team=cin; //team.imbue(locale("en_GB.UTF-8")); if (argc==4){ freopen((string(argv[3]) + "/feedback.txt").c_str(), "w", stdout); } else if (argc!=3){ cerr<<"usage: "< official_plan; { int n; data>>n; for (int i=0; i>item; if (item.find("rest")!=string::npos) official_plan.push_back(REST); else if (item.find("leg")!=string::npos) official_plan.push_back(LEG); else official_plan.push_back(ARM); } for (int i=n; i<31; i++){ official_plan.push_back(official_plan[i%n]); } } vector team_codepoints; { uint8_t team_buf[64*32]={}; size_t team_bytes=fread(team_buf,sizeof(uint8_t),sizeof team_buf,stdin); uint32_t state=0; uint32_t codepoint=0; for (int i=0; i already_used; map already_code; vector team_plan; auto descriptions=unicode_names(); int idx=0; for (auto i: team_codepoints){ if (is_control_code(i) or is_ascii_printable_char(i)){ // We'll be nice and ignore non-emoji characters. continue; } if (is_fitzpatrick_type(i)){ // Modifier. continue; } string desc=descriptions[i]; bool has_rest=(desc.find("face")!=string::npos or desc.find("rest")!=string::npos or desc.find("alien")!=string::npos); bool has_leg=(desc.find("leg")!=string::npos or desc.find("foot")!=string::npos); bool has_arm=(desc.find("arm")!=string::npos or desc.find("bicep")!=string::npos); if (not (has_rest or has_leg or has_arm)){ cout<<"Team codepoint "<