結果
問題 | No.1266 7 Colors |
ユーザー |
![]() |
提出日時 | 2023-09-09 11:54:19 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 317 ms / 3,000 ms |
コード長 | 1,096 bytes |
コンパイル時間 | 5,606 ms |
コンパイル使用メモリ | 312,248 KB |
実行使用メモリ | 14,944 KB |
最終ジャッジ日時 | 2024-06-27 05:00:04 |
合計ジャッジ時間 | 13,181 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include<bits/stdc++.h>using namespace std;#include <atcoder/all>using namespace atcoder;using mint=modint998244353; //1000000007;using ll=long long;using pp=pair<ll,ll>;#define sr string#define vc vector#define fi first#define se second#define rep(i,n) for(ll i=0;i<(ll)n;i++)#define pb push_back#define all(v) v.begin(),v.end()#define pque priority_queue#define bpc(a) __builtin_popcount(a)int main(){int n,m,q;cin>>n>>m>>q;vc<sr>s(n); rep(i,n)cin>>s[i];dsu d(n*7);vc v(n,vc<int>(0));rep(i,m){int a,b;cin>>a>>b; a--;b--;v[a].pb(b);v[b].pb(a);rep(j,7)if(s[a][j]=='1'&&s[b][j]=='1')d.merge(7*a+j,7*b+j);}rep(i,n)rep(j,7){int nj=(j+1)%7;if(s[i][j]=='1'&&s[i][nj]=='1')d.merge(i*7+j,i*7+nj);}rep(z,q){int t,x,y;cin>>t>>x>>y; x--; y--;if(t==1){s[x][y]='1';int ny=(y+1)%7;if(s[x][ny]=='1')d.merge(7*x+y,7*x+ny);ny=(y-1+7)%7;if(s[x][ny]=='1')d.merge(7*x+y,7*x+ny);for(auto au:v[x])if(s[au][y]=='1')d.merge(7*x+y,7*au+y);}else{cout<<d.size(x*7)<<"\n";}}}