結果

問題 No.3025 Chocol∀te
ユーザー tokitsukaze
提出日時 2025-02-15 00:51:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,093 bytes
コンパイル時間 1,523 ms
コンパイル使用メモリ 168,204 KB
実行使用メモリ 34,224 KB
最終ジャッジ日時 2025-02-15 00:52:06
合計ジャッジ時間 28,057 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 35 WA * 42
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |         scanf("%d%d",&n,&m);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:22:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |                 scanf("%d%d",&a,&b);
      |                 ~~~~~^~~~~~~~~~~~~~
main.cpp:28:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |                 scanf("%d",&v[i]);
      |                 ~~~~~^~~~~~~~~~~~
main.cpp:31:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |         scanf("%d",&q);
      |         ~~~~~^~~~~~~~~
main.cpp:34:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |                 scanf("%d",&op);
      |                 ~~~~~^~~~~~~~~~
main.cpp:37:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 |                         scanf("%d%d",&x,&y);
      |                         ~~~~~^~~~~~~~~~~~~~
main.cpp:55:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   55 |                         scanf("%d%d",&x,&y);
      |                         ~~~~~^~~~~~~~~~~~~~
main.cpp:64:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   64 |                         scanf("%d",&x);
      |                         ~~~~~^~~~~~~~~

ソースコード

diff #

#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;
	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);
		mp[a].insert(b);
		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[x]-=v[y];
				sum[y]-=v[x];
				mp[x].erase(y);
				mp[y].erase(x);
			}
			else
			{
				sum[x]+=v[y];
				sum[y]+=v[x];
				mp[x].insert(y);
				mp[y].insert(x);
			}
		}
		else if(op==2)
		{
			scanf("%d%d",&x,&y);
			if(mp[x].size()<=LIMT)
			{
				for(auto &to:mp[x]) sum[to]+=v[x];
			}
			v[x]=y;
		}
		else
		{
			scanf("%d",&x);
			if(mp[x].size()<=LIMT)
			{
				sum[x]=0;
				for(auto &to:mp[x]) sum[x]+=v[to];
			}
			printf("%lld\n",sum[x]);
		}
	}
	return 0;
}
0