# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
785637 | devariaota | Sprinkler (JOI22_sprinkler) | C++17 | 4072 ms | 19884 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> adj[200005];
bool vis[200005];
int arr[200005];
int n, l;
int proses(int x, int d, int w) {
queue<pair<int, int>> q;
vector<int> v;
arr[x] *= w;
arr[x] %= l;
vis[x] = true;
v.push_back(x);
for(int i = 0; i < adj[x].size(); i++) {
vis[adj[x][i]] = true;
v.push_back(adj[x][i]);
q.push({adj[x][i], 1});
}
if(d > 0) {
while(q.size() > 0) {
int a = q.front().first;
int b = q.front().second;
arr[a] *= w;
arr[a] %= l;
if(b < d) {
for(int i = 0; i < adj[a].size(); i++) {
if(vis[adj[a][i]] == false) {
vis[adj[a][i]] = true;
v.push_back(adj[a][i]);
q.push({adj[a][i], b + 1});
}
}
}
q.pop();
}
}
for(int i = 0; i < v.size(); i++) {
vis[v[i]] = false;
}
return 0;
}
signed main() {
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin >> n >> l;
for(int i = 0; i < n - 1; i++) {
int a, b;
cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
}
for(int i = 1; i <= n; i++) {
cin >> arr[i];
}
int q;
cin >> q;
while(q--) {
int a, x;
cin >> a >> x;
if(a == 2) {
cout << arr[x] << "\n";
} else {
int d, w;
cin >> d >> w;
int zzz = proses(x, d, w);
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |