QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#386728 | #5108. Prehistoric Programs | PetroTarnavskyi# | WA | 1ms | 3656kb | C++20 | 2.1kb | 2024-04-11 19:39:36 | 2024-04-11 19:39:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int N = 1 << 18;
int sz[N], cnt[N];
tuple<int, int, int> from[N];
VI g[N];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int m, n, que;
cin >> m >> n >> que;
int mx = 0;
FOR(i, 0, n)
{
char x;
int a, b, c;
cin >> x >> a >> b >> c;
mx = max(mx, a);
mx = max(mx, b);
mx = max(mx, c);
a--; b--; c--;
if(x == 'S')
{
from[b] = {1, a, 0};
from[c] = {1, a, 1};
g[a].PB(b);
g[a].PB(c);
cnt[b] = cnt[c] = 1;
}
else
{
from[c] = {2, a, b};
g[a].PB(c);
g[b].PB(c);
cnt[c] = 2;
}
}
queue<int> q;
FOR(i, 0, mx)
if(cnt[i] == 0)
q.push(i);
sz[0] = m;
while(SZ(q))
{
int v = q.front();
q.pop();
if(v != 0)
{
if(get<0>(from[v]) == 1)
{
sz[v] = sz[get<1>(from[v])] / 2 + (sz[get<1>(from[v])] % 2) * (1 ^ get<2>(from[v]));
}
else
{
sz[v] = sz[get<1>(from[v])] + sz[get<2>(from[v])];
}
cerr << v << " " << sz[v] << "\n";
}
for(int to : g[v])
{
cnt[to]--;
if(cnt[to] == 0)
q.push(to);
}
}
while(que--)
{
int v, k;
cin >> v >> k;
v--; k--;
if(sz[v] <= k)
{
cout << "none\n";
continue;
}
while(v != 0)
{
if(get<0>(from[v]) == 1)
{
k = 2 * k + get<2>(from[v]);
v = get<1>(from[v]);
continue;
}
int a = get<1>(from[v]);
int b = get<2>(from[v]);
if(k <= 2 * min(sz[a], sz[b]))
{
if(k % 2 == 0)
v = a;
else
v = b;
k /= 2;
continue;
}
if(sz[a] > sz[b])
{
v = a;
k -= sz[b];
}
else
{
v = b;
k -= sz[a];
}
}
cout << k + 1 << "\n";
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3656kb
input:
50000 ( ( ))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()( ) ( ) ((( ( ( ( ( ( () ( ) ( )((())()(( )))))( ( ) )) )() ( ) ) )()( ( ( () ( ) ( )()((((())()))())( ( ( )( ( ( (()())()) ) ) ( ( ( )((())))((())))))))))((((()()))()))))))))((()())())) ) )() ) ) ) ) ) ())(())))))()(()((()(())...
output:
result:
wrong output format Unexpected end of file - token expected