結果
| 問題 |
No.3025 Chocol∀te
|
| コンテスト | |
| ユーザー |
wsrtrt
|
| 提出日時 | 2025-02-14 22:47:00 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 3,225 bytes |
| コンパイル時間 | 3,977 ms |
| コンパイル使用メモリ | 306,264 KB |
| 実行使用メモリ | 54,360 KB |
| 最終ジャッジ日時 | 2025-02-14 22:50:32 |
| 合計ジャッジ時間 | 205,645 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 12 TLE * 65 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(a) begin(a),end(a)
#define allr(a) rbegin(a),rend(a)
#define pb push_back
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end())
using ll =long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi= vector<int>;
using vll =vector<ll>;
using vvi = vector<vector<int>>;
inline bool ingrid(int a,int b,int h,int w){
return 0<=a&&a<h&&0<=b&&b<w;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int popcount(int t){return __builtin_popcount(t);}
int popcount(ll t){return __builtin_popcountll(t);}
struct Edge{
int from,to;ll cost;int idx;
Edge()=default;
Edge(int from,int to,ll cost=1,int idx=-1):from(from),to(to),cost(cost),idx(idx){}
operator int() const {return to;}
};
constexpr pii dx4[4]={{0,1},{0,-1},{1,0},{-1,0}};
constexpr pii dx[100]={};
#define endl '\n'
#include<unordered_set>
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n,m;cin>>n>>m;
vi x,y;x.resize(m);y.resize(m);
vector<unordered_set<int>> g(n);
rep(i,0,m){
cin>>x[i]>>y[i];
x[i]--;y[i]--;
g[x[i]].insert(y[i]);
g[y[i]].insert(x[i]);
}
vll A(n);
rep(i,0,n){
cin>>A[i];
}
int B=300;
int q;
cin>>q;
vector<int> cur;//今見ている頂点
vll ans(n);//差分更新しながら使う
vector<tuple<int,int,int>> event;
rep(i,0,q){
int t;
cin>>t;
if(t==1){
int u,v;cin>>u>>v;u--;v--;
event.emplace_back(t,u,v);
}else if(t==2){
int p;ll a;cin>>p>>a;p--;
event.emplace_back(t,p,a);
}else{
int c;int tmp=-1;cin>>c;c--;
event.emplace_back(t,c,tmp);
}
}
rep(i,0,q){
if(i%B==0){
//初期化
rep(j,0,n){
ans[j]=0;
fore(k,g[j]){
ans[j]+=A[k];
}
}
rep(j,i,min(q,i+B)){
int t,u,v;tie(t,u,v)=event[j];
if(t==3){
cur.pb(u);
}
}
UNIQUE(cur);
}
int t,u,v;tie(t,u,v)=event[i];
if(t==1){
if(g[u].find(v)!=g[u].end()){
g[u].erase(v);
g[v].erase(u);
ans[u]-=A[v];
ans[v]-=A[u];
}else{
g[u].insert(v);
g[v].insert(u);
ans[u]+=A[v];
ans[v]+=A[u];
}
}else if(t==2){
int p=u;ll a=v;
fore(j,cur){
if(g[p].find(j)!=g[u].end()){
ans[j]-=A[p];
ans[j]+=v;
}
}
A[p]=v;
}else{
cout<<ans[u]<<endl;
}
}
return 0;
}
/*
*/
wsrtrt