結果
| 問題 | 
                            No.3025 Chocol∀te
                             | 
                    
| コンテスト | |
| ユーザー | 
                             vjudge1
                         | 
                    
| 提出日時 | 2025-02-15 01:30:47 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 496 ms / 2,000 ms | 
| コード長 | 1,154 bytes | 
| コンパイル時間 | 2,147 ms | 
| コンパイル使用メモリ | 199,508 KB | 
| 実行使用メモリ | 24,664 KB | 
| 最終ジャッジ日時 | 2025-02-15 01:31:16 | 
| 合計ジャッジ時間 | 28,407 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 77 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |         scanf("%d%d",&n,&m);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:23:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |                 scanf("%d%d",&a,&b);
      |                 ~~~~~^~~~~~~~~~~~~~
main.cpp:29:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |                 scanf("%d",&v[i]);
      |                 ~~~~~^~~~~~~~~~~~
main.cpp:32:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |         scanf("%d",&q);
      |         ~~~~~^~~~~~~~~
main.cpp:35:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   35 |                 scanf("%d",&op);
      |                 ~~~~~^~~~~~~~~~
main.cpp:38:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |                         scanf("%d%d",&x,&y);
      |                         ~~~~~^~~~~~~~~~~~~~
main.cpp:65:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   65 |                         scanf("%d%d",&x,&y);
      |                         ~~~~~^~~~~~~~~~~~~~
main.cpp:71:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   71 |                         scanf("%d",&x);
      |                         ~~~~~^~~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int MAX=1e5+10;
const int mod=1e9+7;
unordered_set<int> mp[MAX];
ll sum[MAX];
int v[MAX];
const int LIMT=400;
int main()
{
	int n,m,i,a,b,op,x,y,q;
	ll ans;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
	{
		mp[i].clear();
		sum[i]=0;
	}
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&a,&b);
		if(mp[a].size()<=LIMT) mp[a].insert(b);
		else mp[b].insert(a);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d",&v[i]);
		for(auto &to:mp[i]) sum[to]+=v[i];
	}
	scanf("%d",&q);
	while(q--)
	{
		scanf("%d",&op);
		if(op==1)
		{
			scanf("%d%d",&x,&y);
			if(mp[x].count(y))
			{
				sum[y]-=v[x];
				mp[x].erase(y);
			}
			else if(mp[y].count(x))
			{
				sum[x]-=v[y];
				mp[y].erase(x);
			}
			else
			{
				if(mp[x].size()<=LIMT)
				{
					mp[x].insert(y);
					sum[y]+=v[x];
				}
				else
				{
					mp[y].insert(x);
					sum[x]+=v[y];
				}
			}
		}
		else if(op==2)
		{
			scanf("%d%d",&x,&y);
			for(auto &to:mp[x]) sum[to]+=y-v[x];
			v[x]=y;
		}
		else
		{
			scanf("%d",&x);
			ans=sum[x];
			for(auto &to:mp[x]) ans+=v[to];
			printf("%lld\n",ans);
		}
	}
	return 0;
}
            
            
            
        
            
vjudge1