結果
問題 | No.1266 7 Colors |
ユーザー |
![]() |
提出日時 | 2020-10-23 22:28:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 172 ms / 3,000 ms |
コード長 | 1,047 bytes |
コンパイル時間 | 2,379 ms |
コンパイル使用メモリ | 203,904 KB |
最終ジャッジ日時 | 2025-01-15 13:25:37 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:21:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | scanf("%d %d",&u,&v); | ~~~~~^~~~~~~~~~~~~~~ main.cpp:48:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 48 | scanf("%d %d %d",&t,&x,&y); | ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>#include <bits/stdc++.h>#include <atcoder/dsu>using namespace atcoder;using namespace std;#define rep(i,n) for (int i = 0; i < (n); ++i)#define Inf 1000000003int main(){int N,M,Q;cin>>N>>M>>Q;vector<string> S(N);rep(i,N)cin>>S[i];vector<vector<int>> E(N,vector<int>());rep(i,M){int u,v;scanf("%d %d",&u,&v);u--;v--;E[u].push_back(v);E[v].push_back(u);}dsu D(7*N);rep(i,N){rep(j,E[i].size()){int u = i,v = E[i][j];rep(k,7){if(S[u][k]=='1'&&S[v][k]=='1'){D.merge(u*7+k,v*7+k);}}}}rep(i,N){rep(j,7){if(S[i][j]=='1'&&S[i][(j+1)%7]=='1')D.merge(i*7+j,i*7+(j+1)%7);}}rep(i,Q){int t,x,y;scanf("%d %d %d",&t,&x,&y);x--;y--;if(t==1){S[x][y] = '1';rep(j,E[x].size()){int v = E[x][j];if(S[v][y]=='1')D.merge(x*7+y,v*7+y);}if(S[x][(y+1)%7]=='1')D.merge(x*7+y,x*7+(y+1)%7);if(S[x][(y+6)%7]=='1')D.merge(x*7+y,x*7+(y+6)%7);}else{printf("%d\n",D.size(7*x));}}return 0;}