Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
11613 | hhz123 | 【USACO】草地种植 revegetate(USACO 2019) | C++ | 通过 | 0 MS | 256 KB | 522 | 2022-10-06 16:04:22 |
#include <bits/stdc++.h> using namespace std; const int N=110; const int M=310; int h[N],e[M],ne[M],idx; bool st[N][5]; void add(int a,int b){ e[idx]=b; ne[idx]=h[a]; h[a]=idx++; } int main(){ int n,m; cin>>n>>m; memset(h,-1,sizeof(h)); while(m--){ int a,b; cin>>a>>b; add(a,b); add(b,a); } for(int i=1;i<=n;i++){ for(int j=1;j<=4;j++){ if(!st[i][j]){ cout<<j; for(int k=h[i];k!=-1;k=ne[k]){ int x=e[k]; st[x][j]=true; } break; } } } }