WPBDC 2013.1.5 → 2013.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/ext/WPBDC/WPBDC.c +13 -0
- data/ext/WPBDC/judge.c +0 -1
- data/ext/WPBDC/judge.h +4 -0
- data/ext/WPBDC/scenario.c +36 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzQ1ZDYzZTUzNzI0ZTkzMzU5ZWVlM2E3MDIxNDY3ZTVkYzBjMDcxYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTgyNTliYWJjYzQyZmQ5NWVlMTBiMTU1Yjk5N2UxYjU4MzA0ZTI1Mg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzljYWFjNDljZGU0YzAxNjJlNGVhN2NjOTc2MDg4MDhjYWY5NWQxYjc2ZGNi
|
10
|
+
MTA0OGNkZjE2NDFkMWY5YjBjZjE4ODdiZmZjYTMzOWJkOGRkNWQzMGMyMmMz
|
11
|
+
NDNkZDM2OTRiNDk1MmVmNGU1ZDQ0Y2UxZWVkNGQ2YTNlYmY0ODk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Mzc1MjQ5NGFmODQ1Zjk1YzJhMzlkNmViNDMyNTIwMzUwMmRjZDRiNzM3MmQz
|
14
|
+
OTI5YmNmZWYxZjE3YTg0MjUzYmI5N2IxMjExMzU3OGE4MmEwOGM3MWI2NTU2
|
15
|
+
ZDU4NGYyNzRmYjAyYzc2NjQ4YjVlZDFkMDhhNjMwM2I5ZmYxNzY=
|
data/ext/WPBDC/WPBDC.c
CHANGED
@@ -220,6 +220,15 @@ static struct ict_entry {
|
|
220
220
|
INT_CONST_TABLE_ENTRY(SCENARIO_NUMBER_SIZE),
|
221
221
|
};
|
222
222
|
|
223
|
+
#define STRING_CONST_TABLE_ENTRY(Name) { #Name, Name }
|
224
|
+
|
225
|
+
static struct sct_entry {
|
226
|
+
char *name;
|
227
|
+
char *val;
|
228
|
+
} string_const_table[] = {
|
229
|
+
STRING_CONST_TABLE_ENTRY(SEMIFINAL_SCENARIO_ID)
|
230
|
+
};
|
231
|
+
|
223
232
|
void Init_WPBDC(void)
|
224
233
|
{
|
225
234
|
int i;
|
@@ -235,4 +244,8 @@ void Init_WPBDC(void)
|
|
235
244
|
struct ict_entry *e = int_const_table + i;
|
236
245
|
rb_define_const(module, e->name, INT2FIX(e->val));
|
237
246
|
}
|
247
|
+
for (i = 0; i < STATIC_ARRAY_SIZE(string_const_table); i++) {
|
248
|
+
struct sct_entry *e = string_const_table + i;
|
249
|
+
rb_define_const(module, e->name, rb_str_new2(e->val));
|
250
|
+
}
|
238
251
|
}
|
data/ext/WPBDC/judge.c
CHANGED
data/ext/WPBDC/judge.h
CHANGED
@@ -15,6 +15,10 @@
|
|
15
15
|
#define YEAR_TO_VERSION(Y) (((((Y) % 100) / 10) << 8) | (((Y) % 10) << 4) | 0x400c)
|
16
16
|
#define BD_VERSION YEAR_TO_VERSION(CONTEST_YEAR)
|
17
17
|
|
18
|
+
// The id for the semifinal scenario including a null value
|
19
|
+
#define NULL_SEMIFINAL_SCENARIO_ID "0000000000"
|
20
|
+
#define SEMIFINAL_SCENARIO_ID NULL_SEMIFINAL_SCENARIO_ID
|
21
|
+
|
18
22
|
// Status returns from analyze().
|
19
23
|
#define BRIDGE_OK 0
|
20
24
|
#define BRIDGE_MALFORMED 1
|
data/ext/WPBDC/scenario.c
CHANGED
@@ -8,7 +8,9 @@
|
|
8
8
|
// The indices do _not_ have to be in order.
|
9
9
|
|
10
10
|
// Lookup table is sorted on 10-char ID field for binary search.
|
11
|
+
// The search routine will bubble the semifinal row to the right location.
|
11
12
|
static TScenarioDescriptor scenario_descriptor_tbl[] = {
|
13
|
+
{ 999, SEMIFINAL_SCENARIO_ID, "99Z", 100000.00 },
|
12
14
|
{ 0, "1050824100", "27A", 99874.40 },
|
13
15
|
{ 1, "1051220100", "32A", 105140.00 },
|
14
16
|
{ 2, "1051616100", "36A", 111994.40 },
|
@@ -427,23 +429,42 @@ char *local_contest_number_to_id(char *number)
|
|
427
429
|
int lookup_scenario_descriptor(TScenarioDescriptor *desc, char *id)
|
428
430
|
{
|
429
431
|
static TScenarioDescriptor null_desc = NULL_SCENARIO_DESCRIPTOR;
|
432
|
+
static int initialized_p = 0;
|
430
433
|
int lo = 0;
|
431
434
|
int hi = STATIC_ARRAY_SIZE(scenario_descriptor_tbl) - 1;
|
432
|
-
int cmp, mid;
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
435
|
+
int i, cmp, mid;
|
436
|
+
|
437
|
+
// Bubble the semifinal scenario to the right position one time.
|
438
|
+
if (!initialized_p) {
|
439
|
+
initialized_p = 1;
|
440
|
+
TScenarioDescriptor semifinal_descriptor = scenario_descriptor_tbl[0];
|
441
|
+
for (i = 0; i < STATIC_ARRAY_SIZE(scenario_descriptor_tbl) - 1; i++) {
|
442
|
+
if (strncmp(scenario_descriptor_tbl[i + 1].id, semifinal_descriptor.id, SCENARIO_ID_SIZE) < 0)
|
443
|
+
scenario_descriptor_tbl[i] = scenario_descriptor_tbl[i + 1];
|
444
|
+
else
|
445
|
+
break;
|
446
|
+
}
|
447
|
+
scenario_descriptor_tbl[i] = semifinal_descriptor;
|
448
|
+
}
|
449
|
+
|
450
|
+
// Don't bother searching for the null semifinal scenario.
|
451
|
+
if (strncmp(id, NULL_SEMIFINAL_SCENARIO_ID, SCENARIO_ID_SIZE) != 0) {
|
452
|
+
|
453
|
+
while (lo <= hi) {
|
454
|
+
mid = (unsigned)(lo + hi) >> 1;
|
455
|
+
cmp = strncmp(id, scenario_descriptor_tbl[mid].id, SCENARIO_ID_SIZE);
|
456
|
+
if (cmp < 0)
|
457
|
+
hi = mid - 1;
|
458
|
+
else if (cmp > 0)
|
459
|
+
lo = mid + 1;
|
460
|
+
else {
|
461
|
+
if (desc)
|
462
|
+
*desc = scenario_descriptor_tbl[mid];
|
463
|
+
return mid;
|
464
|
+
}
|
465
|
+
}
|
466
|
+
|
467
|
+
}
|
447
468
|
if (desc)
|
448
469
|
*desc = null_desc;
|
449
470
|
return -1;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: WPBDC
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2013.1.
|
4
|
+
version: 2013.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gene Ressler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Container for C code extension that implements the West Point Bridge
|
14
14
|
Contest Judge.
|