QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#182236 | #7103. Red Black Tree | zipdang04# | WA | 1ms | 5940kb | C++14 | 4.0kb | 2023-09-17 15:19:39 | 2023-09-17 15:19:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
*/
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
template <class T> using PQMax = priority_queue<T>;
template <class T> using PQMin = priority_queue<T, vector<T>, greater<T>>;
template <class T1, class T2>
void maximize(T1 &a, T2 b){
if (b > a) a = b;
}
template <class T1, class T2>
void minimize(T1 &a, T2 b){
if (b < a) a = b;
}
template <class T>
void read(T &number)
{
bool negative = false;
register int c;
number = 0;
c = getchar();
while (c != '-' && !isalnum(c)) c = getchar();
if (c=='-'){
negative = true;
c = getchar();
}
for (; (c>47 && c<58); c=getchar())
number = number *10 + c - 48;
if (negative)
number *= -1;
}
template <class T, class ...Ts>
void read(T &a, Ts& ... args){
read(a);
read(args...);
}
/*
struct Node
{
int node, len;
Node() {node = len = 0;}
Node(int node, int len) {this -> node = node, this -> len = len;}
};
typedef vector<Node> vg;
*/
#define MAX 10005
#define MOD 256
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define FOR(type, i, a, b) for(type i = (a); i <= (b); i++)
#define FORD(type, i, b, a) for(type i = (b); i >= (a); i--)
#define testBit(n, bit) (((n) >> (bit)) & 1)
#define flipBit(n, bit) ((n) ^ (1ll << (bit)))
#define cntBit(n) __builtin_popcount(n)
#define cntBitll(n) __builtin_popcountll(n)
#define randomize mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
struct Instruction{
string instruction;
int v, k;
Instruction(){
instruction = "";
v = k = 0;
}
Instruction(string instruction, int v, int k){
this -> instruction = instruction;
this -> v = v;
this -> k = k;
}
};
struct State{
int value, position;
};
bool operator == (State a, State b){
return (a.value == b.value) && (a.position == b.position);
}
int n;
Instruction instructions[MAX];
bool visited[MAX][MOD];
State process(State state, Instruction instruction){
if (instruction.instruction == "add"){
state.value += instruction.v; state.value %= MOD;
state.position++;
return state;
}
if (instruction.instruction == "beq")
state.position = (state.value == instruction.v ? instruction.k : state.position + 1);
else if (instruction.instruction == "bne")
state.position = (state.value != instruction.v ? instruction.k : state.position + 1);
else if (instruction.instruction == "blt")
state.position = (state.value < instruction.v ? instruction.k : state.position + 1);
else // if (instruction.instruction == "bgt")
state.position = (state.value > instruction.v ? instruction.k : state.position + 1);
return state;
}
main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int t; cin >> t;
FOR(int, _, 1, t){
cin >> n;
FOR(int, i, 1, n){
string ins; int v, k; cin >> ins >> v;
if (ins != "add") cin >> k;
instructions[i] = Instruction(ins, v, k);
}
FOR(int, i, 0, n + 1)
memset(visited[i], false, sizeof(visited[i]));
bool answer = true;
State state = {0, 1}; visited[0][1] = true;
while (state.position < n + 1){
state = process(state, instructions[state.position]);
if (visited[state.value][state.position]){
answer = false;
break;
}
visited[state.value][state.position] = true;
}
cout << (answer ? "Yes\n" : "No\n");
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5940kb
input:
2 12 2 4 1 9 1 2 1 2 3 4 3 4 3 3 5 2 2 6 2 6 7 1 6 8 2 2 9 5 9 10 2 9 11 3 1 12 10 3 3 7 8 4 4 5 7 8 4 7 8 10 11 3 4 5 12 3 2 3 1 2 1 2 1 1 3 1 1 1 2 1 2 3 1 2 3
output:
Yes Yes
result:
wrong answer 1st lines differ - expected: '4', found: 'Yes'