编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#47464 | #1262. 系统漏洞 | Compile Error | 0 | 0 ms | 0 K | C++ 11 (Clang) / 1.7 K | Rhodoks | 2021-04-23 20:17:15 |
#include <bits/stdc++.h>
#define DB double
#define LL long long
#define MST(a, b) memset((a), (b), sizeof(a))
#ifdef _DEBUG_
#define MRK() cout << "Mark" << endl;
#define WRT(x) cout << #x << " = " << (x) << endl;
#else
#define MRK() ;
#define WRT(x) ;
#endif
#define MAXN 1010000
#define MAXM 2010000
#define MOD 998244353 // 1000000007
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-5
#define _ 0
using namespace std;
typedef pair<int, LL> pil;
vector<pil> g[MAXN];
int n, m;
int val[MAXN];
LL mpow(LL x, LL n) {
LL ans = 1;
while (n) {
if (n & 1)
ans = ans * x % MOD;
x = x * x % MOD;
n >>= 1;
}
return ans;
}
LL inv(LL x) { return mpow(x, MOD - 2); }
void init() {}
bool dfs(int pos) {
for (auto p : g[pos]) {
if (val[p.first]) {
if (val[p.first] != val[pos] * p.second % MOD)
return false;
} else {
val[p.first] = val[pos] * p.second % MOD;
if (!dfs(p.first))
return false;
}
}
return true;
}
bool check() {
for (int i = 1; i <= n; i++) val[i] = 0;
for (int i = 1; i <= n; i++)
if (val[i] == 0) {
val[i] = 1;
if (!dfs(i))
return false;
}
return true;
}
void work() {
int x, y;
LL w;
cin >> n >> m;
for (int i = 0; i < m; i++) {
scanf("%d%d%lld", &x, &y, &w);
g[x].push_back({ y, w });
g[y].push_back({ x, inv(w) });
}
if (check())
cout << "Yes" << endl;
else
cout << "No" << endl;
}
int main() {
#ifdef _DEBUG_
freopen("C:/Users/DELL/Documents/Dev-C++/sample.in", "r", stdin);
#endif
init();
int casenum = 1;
// scanf("%d",&casenum);
for (int testcase = 1; testcase <= casenum; testcase++) {
#ifdef _DEBUG_
printf("Case #%d:\n", testcase);
#endif
work();
}
return ~~(0 ^ _ ^ 0);
}
编译信息
clang: error: unable to execute command: Killed
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 7.0.1-svn347285-1~exp1~20181124105316.38 (branches/release_70)
Target: x86_64-pc-linux-gnux32
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/a-12fd88.cpp
clang: note: diagnostic msg: /tmp/a-12fd88.sh
clang: note: diagnostic msg:
********************