結果
| 問題 | No.3639 Itsukin |
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2026-08-25 14:14:27 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 154 ms / 2,000 ms |
| + 292µs | |
| コード長 | 1,659 bytes |
| 記録 | |
| コンパイル時間 | 4,375 ms |
| コンパイル使用メモリ | 384,624 KB |
| 実行使用メモリ | 20,744 KB |
| 最終ジャッジ日時 | 2026-08-25 14:15:46 |
| 合計ジャッジ時間 | 10,690 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| サンプル | 0 % | AC * 1 |
| 小課題1 | 10 % | AC * 6 |
| 小課題2 | 15 % | AC * 5 |
| 小課題3 | 15 % | AC * 16 |
| 小課題4 | 20 % | AC * 10 |
| 小課題5 | 10 % | AC * 15 |
| 小課題6 | 30 % | AC * 35 |
| 合計 | 100 点 |
ソースコード
/**
author: shobonvip
created: 2026.08.25 14:10:58
**/
#include<bits/stdc++.h>
using namespace std;
//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/
/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/
typedef long long ll;
#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)
#define all(v) v.begin(), v.end()
template <typename T> bool chmin(T &a, const T &b) {
if (a <= b) return false;
a = b;
return true;
}
template <typename T> bool chmax(T &a, const T &b) {
if (a >= b) return false;
a = b;
return true;
}
template <typename T> T max(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
return ret;
}
template <typename T> T min(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
return ret;
}
template <typename T> T sum(vector<T> &a){
T ret = 0;
for (int i=0; i<(int)a.size(); i++) ret += a[i];
return ret;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
dsu uf(n);
vector<tuple<int,int,int,int>> event;
rep(i,0,m) {
int u,v,l;
cin >> u >> v >> l; u--; v--;
event.emplace_back(l,0,u,v);
}
int q; cin >> q;
rep(i,0,q) {
int p, t; cin >> p >> t; t--;
event.emplace_back(p,1,i,t);
}
vector<int> ans(q);
sort(all(event));
for (auto [_,t,u,v]: event) {
if (t == 0) {
uf.merge(u, v);
} else {
ans[u] = uf.size(v);
}
}
rep(i,0,q) cout << ans[i] << '\n';
}
shobonvip