QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#485212 | #8591. Shops | Issa | 0 | 176ms | 69968kb | C++14 | 1020b | 2024-07-20 15:04:51 | 2024-07-20 15:04:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ent "\n"
const int maxn = 1e6 + 100;
const ll INF = (ll)1e18 + 100;
const int inf = 1e9 + 100;
const int MOD = 1e9 + 7;
const int maxl = 26;
const int P = 31;
int n, m;
vector<pii> g[maxn];
int c[maxn];
bool ok = 1;
void dfs(int v){
for(auto [to, w]: g[v]){
if(c[to] < 0){
c[to] = c[v] ^ 1;
dfs(to);
} else if(c[to] == c[v]) ok = 0;
}
}
void test(){
cin >> n >> m;
for(int i = 1; i <= m; i++){
int a, b, c;
cin >> a >> b >> c;
g[a].push_back({b, c});
g[b].push_back({a, c});
}
fill(c, c + n + 1, -1);
ok = 1; c[1] = 0; dfs(1);
if(ok){
cout << 1 << endl;
} else{
cout << 2 << endl;
}
for(int i = 1; i <= n; i++){
if(c[i]) cout << 'D';
else cout << 'R';
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t; t = 1;
while(t--) test();
cout << ent;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 27696kb
input:
3 3 1 2 3 2 3 1 1 3 2
output:
2 RDR
result:
wrong answer Token "RDR" doesn't correspond to pattern "[BD]*"
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 111ms
memory: 69968kb
input:
500000 499999 1 2 776715136 2 3 406881694 3 4 265792290 4 5 507607272 5 6 182246639 6 7 997847597 7 8 164130256 8 9 278962226 9 10 411194641 10 11 363646402 11 12 672225656 12 13 494629089 13 14 717664153 14 15 121619271 15 16 476857704 16 17 301215244 17 18 810217743 18 19 850722975 19 20 10710274 ...
output:
1 RDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRD...
result:
wrong answer Token "RDRDRDRDRDRDRDRDRDRDRDRDRDRDRD...DRDRDRDRDRDRDRDRDRDRDRDRDRDRDRD" doesn't correspond to pattern "[BD]*"
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 176ms
memory: 50128kb
input:
366489 397001 2 127909 1 7 171229 1 8 158597 1 11 282213 1 14 356007 1 15 286102 1 16 93205 1 17 260111 1 18 138962 1 20 359938 1 29 223905 1 31 357684 1 32 259968 1 34 65205 1 37 200276 1 41 83195 1 43 159858 1 48 332277 1 50 320322 1 51 338467 1 53 262785 1 55 83815 1 56 173198 1 58 169473 1 63 19...
output:
2 RRRRDDDRDRDRRDDDDRRDDRRDDDRRDRDDRDDDDRDDRRRRRDDDRDRDDDRRRRRDRDRRDRDDRDDRRRDDRRDRRRRDDRDRRDDDDRDRDDDDRDRRDRRDDDDRDDRRDRDRDDRRRDRDRRRRDRRRRRRDRRDRRDDDDRDRRRDRRRRRDDDRRDDRDDDRRDDRDRRRRRRRDRDDDRDRRRDDRDRRRDRDRRRRRDDRDRDRRRRDRRRRRRRDRRDRDRDDDRDRDDRRDRRDDRRRDRDDDRDDRRRRRDRRRRRRRDRRDRDRDRRDRRRRDRRDDRDDDR...
result:
wrong answer Token "RRRRDDDRDRDRRDDDDRRDDRRDDDRRDR...DRRDRRDRRRDRRRRDDDRRRRDDRDDDRRR" doesn't correspond to pattern "[BD]*"
Subtask #5:
score: 0
Skipped
Dependency #1:
0%