Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
100233 陈志轩 四色地图 C++ 运行超时 70 794 MS 248 KB 1308 2023-08-25 09:51:13

Tests(7/10):


#include<bits/stdc++.h> #define int long long using namespace std; namespace Fast{ inline int fr(){ int x = 0,f = 1; char c = getchar(); while (c < '0' || c > '9'){ if (c == '-'){ f = -1; } c = getchar(); } while (c >= '0' && c <= '9'){ x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } inline void fw(int x){ if (x < 0){ x = -x; putchar('-'); } if (x > 9){ fw(x / 10); } putchar(x % 10 + 48); } } using namespace Fast; int ret[35],n,sum; bool mp[35][35]; bool check(int x,int y){ for (int i = 1;i <= n;i++){ if (mp[x][i] && ret[i] == y){ return false; } } return true; } void dfs(int cur){ if (cur > n){ for (int i = 1;i <= n;i++){ cout<<ret[i]<<' '; } exit(0); } for (int i = 1;i <= 4;i++){ if (check(cur,i)){ ret[cur] = i; dfs(cur + 1); ret[cur] = 0; } } } signed main(){ n = fr(); getchar(); for (int i = 1;i <= n;i++){ int a = fr(); int sum = 0; while (1){ char c = getchar(); if (c == '\n'){ mp[a][sum] = true; break; } if (c < '0' || c > '9'){ mp[a][sum] = true; sum = 0; } else{ sum = (sum << 1) + (sum << 3) + (c ^ 48); } } } dfs(1); return 0; }


测评信息: