资源简介
ctsc解题报告和测试数据。
代码片段和文件信息
#include
#include
#include
#include
#include
#include
using namespace std;
ifstream inp(“logic.in“);
ofstream out(“logic.out“);
#define cin inp
//#define cout out
int instack[128] = {0};
int outstack[128] = {0};
struct rec
{
int op[200];
int n1[200]n2[200];
bool ch[26];
int ans;
int tch;
};
int commonch;
int weight[26];
bool result[1024];
bool myisalpha(const char& c)
{
return (c >= ‘a‘ && c <= ‘z‘);
}
int process(char str[] rec& a)
{
a.ans = 25;
int i = 0 jkkin;
bool lastalpha = false;
stack op;
stack n;
int len = strlen(str);
memset(a.ch 0 sizeof(a.ch));
while (1)
{
if (i < len && myisalpha(str[i]))
{
if (lastalpha)
{
len = i;
continue;
}
j = (int)str[i++]-‘a‘;
n.push(j);
a.ch[j] = true;
lastalpha = true;
continue;
}
k = 0;
if (i < len)
{
k = outstack[str[i]];
if (outstack[str[i]] >= 9 && lastalpha)
{
len = i;
k = 0;
}
}
while (1)
{
kin = 0;
if (op.size() > 0) kin = instack[op.top()];
if (k >= kin) break;
a.ans++;
op.pop();
a.n1[a.ans] = n.top();
n.pop();
a.op[a.ans] = kin/2;
if (kin != 8)
{
a.n2[a.ans] = n.top();
n.pop();
}
n.push(a.ans);
}
lastalpha = false;
if (k == kin)
{
if (k == 0) break;
if (k == 1)
{
op.pop();
lastalpha = true;
}
}
else
op.push(str[i]);
i++;
}
if (a.ans < 26)
{
a.ans = n.top();
}
a.tch = 0;
for (i = 0; i < 26; i++)
if (a.ch[i]) a.tch++;
//cerr << len << endl;
return len;
}
bool check(const rec& a bool init)
{
int ii1jfk = (1 << a.tch);
bool b;
bool r[200];
for (i = 0; i < k; i++)
{
i1 = i;
f = 0;
b = init;
for (j = 0; j < 26; j++)
if (a.ch[j])
{
r[j] = i1%2;
i1 >>= 1;
if (r[j])
{
if (weight[j] > 0) f += weight[j];
else b = false;
}
}
for (j = 26; j <= a.ans; j++)
if (a.op[j] == 1) r[j] = r[a.n1[j]] | r[a.n2[j]];
else if (a.op[j] == 2) r[j] = r[a.n1[j]] ^ r[a.n2[j]];
else if (a.op[j] == 3) r[j] = r[a.n1[j]] & r[a.n2[j]];
else if (a.op[j] == 4) r[j] = !r[a.n1[j]];
if (b)
result[f] = r[a.ans];
else
if (result[f] != r[a.ans]) return false;
}
return true;
}
bool work()
{
char str[1001] s1[1001];
cin.getline(s1 1000);
int i = 0 j;
for (j = 0; s1[j] != 0; j++)
if ((s1[j] >= ‘a‘ && s1[j] <= ‘z‘) || (s1[j] >= 0 && s1[j] < 128 && instack[s1[j]] != 0))
str[i++] = s1[j];
str[i] = 0;
//cerr << str << endl;
rec left right;
i = process(str left);
process(str+i right);
commonch = 0;
memset(weight 0 sizeof(weight));
i = 1;
for (j = 0; j < 26; j++)
if (left.ch[j] && right.ch[j])
{
commonch++;
weight[j] = i;
i <<= 1;
}
//cerr << commonch << endl;
//cerr << weight[0] << endl;
if (!chec
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 407673 2004-05-11 18:51 ctsc\ctsc2004\day2\day2.pdf
文件 202752 2004-05-11 18:48 ctsc\ctsc2004\day2\day2.doc
文件 9936 2004-05-10 15:01 ctsc\ctsc2004\day2\standard\maths.cpp
文件 16595 2004-05-11 02:24 ctsc\ctsc2004\day2\standard\network.dpr
文件 16396 2004-05-10 20:38 ctsc\ctsc2004\day2\standard\network.pas
目录 0 2004-05-30 19:09 ctsc\ctsc2004\day2\standard
文件 6 2004-05-08 22:31 ctsc\ctsc2004\day2\testdata_assembly\assembly1.ans
文件 85 2004-04-28 14:30 ctsc\ctsc2004\day2\testdata_assembly\assembly1.in
文件 84 2004-05-01 20:26 ctsc\ctsc2004\day2\testdata_assembly\assembly1.std
文件 8 2004-05-10 14:43 ctsc\ctsc2004\day2\testdata_assembly\assembly2.ans
文件 1099 2004-05-10 14:38 ctsc\ctsc2004\day2\testdata_assembly\assembly2.in
文件 1097 2004-05-10 14:40 ctsc\ctsc2004\day2\testdata_assembly\assembly2.std
文件 14 2004-05-08 22:31 ctsc\ctsc2004\day2\testdata_assembly\assembly3.ans
文件 572 2004-05-05 21:27 ctsc\ctsc2004\day2\testdata_assembly\assembly3.in
文件 574 2004-05-07 00:40 ctsc\ctsc2004\day2\testdata_assembly\assembly3.std
文件 16 2004-05-10 14:12 ctsc\ctsc2004\day2\testdata_assembly\assembly4.ans
文件 14263 2004-04-27 15:59 ctsc\ctsc2004\day2\testdata_assembly\assembly4.in
文件 14264 2004-05-10 14:08 ctsc\ctsc2004\day2\testdata_assembly\assembly4.std
文件 16 2004-05-10 14:09 ctsc\ctsc2004\day2\testdata_assembly\assembly5.ans
文件 56886 2004-04-27 15:59 ctsc\ctsc2004\day2\testdata_assembly\assembly5.in
文件 56886 2004-05-04 13:44 ctsc\ctsc2004\day2\testdata_assembly\assembly5.std
文件 16 2004-05-10 14:14 ctsc\ctsc2004\day2\testdata_assembly\assembly6.ans
文件 166930 2004-05-10 12:44 ctsc\ctsc2004\day2\testdata_assembly\assembly6.in
文件 166930 2004-05-10 14:11 ctsc\ctsc2004\day2\testdata_assembly\assembly6.std
文件 16 2004-05-10 14:13 ctsc\ctsc2004\day2\testdata_assembly\assembly7.ans
文件 226738 2004-04-27 16:00 ctsc\ctsc2004\day2\testdata_assembly\assembly7.in
文件 226738 2004-05-04 13:46 ctsc\ctsc2004\day2\testdata_assembly\assembly7.std
文件 18 2004-05-10 14:13 ctsc\ctsc2004\day2\testdata_assembly\assembly8.ans
文件 1416131 2004-05-04 14:26 ctsc\ctsc2004\day2\testdata_assembly\assembly8.in
文件 1416131 2004-05-10 14:13 ctsc\ctsc2004\day2\testdata_assembly\assembly8.std
............此处省略949个文件信息
- 上一篇:STM32_UVC
- 下一篇:protel99se教学完整版
评论
共有 条评论