結果
| 問題 | No.3552 Triangular Coloring |
| コンテスト | |
| ユーザー |
みたに
|
| 提出日時 | 2026-05-23 17:49:04 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,996 bytes |
| 記録 | |
| コンパイル時間 | 2,603 ms |
| コンパイル使用メモリ | 354,364 KB |
| 実行使用メモリ | 78,368 KB |
| 最終ジャッジ日時 | 2026-05-23 17:49:45 |
| 合計ジャッジ時間 | 18,476 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | RE * 16 TLE * 1 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define Yes cout << "Yes" << "\n"
#define No cout << "No" << "\n"
#define rtr0 return(0)
#define all(x) x.begin(), x.end()
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
//using mint=static_modint<998244353>;
//using mint=static_modint<1000000007>;
////using mint=modint;
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
using ll=long long;
using l3=__int128;
using ull=unsigned long long;
using ld=long double;
using P=pair<ll,ll>;
const ld PI=acos(-1);
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
void yn(bool f){cout<<(f?"Yes":"No")<<endl;}
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};
const int inf=1001001001;
const ll INF=1001001001001001001;
ll mod=998244353;
void solve(){
ll n,m;cin>>n>>m;
vector<set<ll>> g(n);
vector<ll> d(n);
rep(i,m){
ll u,v;cin>>u>>v;u--;v--;
g[u].insert(v);
g[v].insert(u);
d[u]++;
d[v]++;
}
priority_queue<ll,vector<ll>,greater<ll>> pq;
vector<vector<ll>> pa(n,vector<ll>(3,-1));
rep(i,n)if(d[i]==3)pq.push(i);
vector<ll> s;
while(!pq.empty()){
auto id=pq.top();pq.pop();
s.push_back(id);
ll i=0;
for(auto nex:g[id]){
pa[id][i]=nex;
d[nex]--;
if(d[nex]==3){
g[nex].erase(id);
pq.push(nex);
}
i++;
}
}
reverse(all(s));
vector<ll> ans(n);
rep(i,n){
ll id=0;
set<ll> st;
rep(j,4)st.insert(j+1);
rep(j,4)if(st.count(ans[pa[s[i]][j]]))st.erase(ans[pa[s[i]][j]]);
ans[s[i]]=*st.begin();
}
cout<<"Yes"<<endl;
for(auto x:ans)cout<<x<<endl;
}
int main(){
ll t=1;
//cin>>t;
rep(i,t)solve();
}
みたに