이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
using namespace std;
#include <vector>
#define vi vector<int>
#define ll long long
#include <algorithm>
#include <set>
#include <string>
#include <bitset>
#include <cmath>
#include <math.h>
#define pll pair<ll,ll>
#define vll vector<ll>
#define pi pair<int,int>
#include <map>
#include <queue>
#define x first
#define y second
#define pd pair<double,double>
const int siz = 1e5 + 1;
int ans[siz];
vi ed[siz];
vector<vi> e;
vector<vi> q2;
multiset<pi> fr[siz];
void dfs(int i, int b,bitset<siz>&v) {
if (v[i])return;
v[i] = 1;
for (pi f : fr[i]) {
if (f.y >= b) {
dfs(f.x,b,v);
}
}
}
vi c[siz];
int my[siz];
void con(int a, int b) {
int u = my[a], v = my[b];
if (u == v)return;
if (c[u].size() > c[v].size())swap(u, v);
for (int i : c[u]) {
my[i] = v;
c[v].push_back(i);
}
}
struct node {
int l, r, mini, mid;
node* sl, * sr;
node(int li, int ri) {
l = li, r = ri, mid = (l + r) / 2;
if (l < r) {
sl = new node(li, mid);
sr = new node(mid + 1, ri);
mini = min(sl->mini, sr->mini);
}
else {
mini = e[l][0];
}
}
void update(int i, int val) {
if (l == r) {
mini = val;
}
else {
if (i <= mid)sl->update(i, val);
else sr->update(i, val);
mini = min(sl->mini, sr->mini);
}
}
pi query(int a, int t) {
if (mini >= t)return { l,r };
if (l == r)return { -1,-2 };
if (a <= mid) {
if (l == r)return { l-1,l-1};
if (sl->mini >= t) {
return { l,sr->query(a,t).second };
}
else {
pi p = sl->query(a, t);
if (p.y == mid)return { p.x,sr->query(a,t).second };
else return p;
}
}
else {
if (l == r)return { l + 1,l + 1 };
if (sr->mini >= t) {
int s = sl->query(a, t).first; if (s <= -1)return { mid + 1,r };
return { s,r };
}
else {
pi p = sr->query(a, t);
if (p.x == 1 + mid) {
int s = sl->query(a, t).first; if (s <= -1)return { mid + 1,r };
return { s,p.y };
//return { sl->query(a,t).first ,p.y };
}
else return p;
}
}
}
};
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL);
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int u, v, d;
cin >> u >> v >> d;
u--, v--;
fr[u].insert({ v,d });
fr[v].insert({ u,d });
ed[i] = { d,u,v };
e.push_back({ d,u,v });
}for (int i = 0; i < n; i++) {
c[i].push_back(i);
my[i] = i;
}
int q;
cin >> q;
node* seg = new node(0, n - 2);
for (int i = 0; i < q; i++) {
int t,a,b;
cin >> t>>a>>b;
a--;
if (t == 1) {
seg->update(a, b);
}
else {
seg->query(a, b).second - seg->query(a, b).first + 2;
}
}
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
컴파일 시 표준 에러 (stderr) 메시지
bridges.cpp: In function 'int main()':
bridges.cpp:132:62: warning: value computed is not used [-Wunused-value]
132 | seg->query(a, b).second - seg->query(a, b).first + 2;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
# | 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... |