P17648 [IO 2025 #1] Battle with Bosses
Description
Hornet has $n$ battle attributes; the value of the $i$-th attribute is an integer $a_i$. During her long adventure, she meets $m$ bosses, each of which also has these $n$ attributes: the $j$-th attribute of the $i$-th boss is $b_{i,j}$.
Hornet does not necessarily fight the bosses in increasing order of their indices, nor does she necessarily fight each boss only once. She has an array $c$ of boss indices of length $k$ that determines which bosses she fights. The values in $c$ may repeat, and not every index from $1$ to $m$ has to appear.
During the adventure, two kinds of events may happen:
1. `1 i x`: Hornet's $i$-th attribute increases by $x$, i.e., $a_i\gets a_i+x$.
2. `2 j s`: Hornet fights the boss with index $c_j$. If $s$ is `win`, the record says she won; if $s$ is `loss`, the record says she lost.
Hornet can defeat the boss with index $c_j$ if and only if each of her attributes is at least the corresponding attribute of that boss, i.e., $a_i\ge b_{c_j,i}$ for all $i$. Therefore, she loses as long as at least one of her attributes is lower than the boss's corresponding attribute.
Unfortunately, the values $c_j$ in the array have been lost, but the records of all events remain. Determine whether there exists an array $c$ such that the actual results of all battles match the records, or whether the records contain errors. The same index $j$ appearing in different events always refers to the same $c_j$.
Input Format
The first line contains three integers $n,m,k$, the number of battle attributes, bosses, and events, with $1\le n,m,k\le1000$. The length of the array $c$ is also $k$.
The second line contains $n$ integers $a_i$, the initial values of Hornet's attributes, with $0\le a_i\le500$.
Each of the next $m$ lines contains $n$ integers $b_{i,j}$, the attributes of one boss, with $0\le b_{i,j}\le500$.
The next $k$ lines give the event records in the format described above, where $1\le i\le n$, $1\le j\le k$, $1\le x\le500$, and $s$ is `win` or `loss`.
Output Format
If there exists an array $c$ making the event records correct, output `Yes`; otherwise output `No`.
Note that Hornet is not required to fight every boss at least once.
Explanation/Hint
### Explanation for Sample 1
We can choose $c=[*,1,2,*]$, where $*$ denotes any boss index, since the records contain no information about these positions.
Before fighting any boss, Hornet's attributes are $[2,3,0]$. With these attributes she can defeat the first boss but would lose to the second boss.
### Explanation for Sample 2
No valid array exists. Before the last event, Hornet's attributes are $[2,3,3]$, so she would not lose to any boss.
Translated by QwenWork