#include "Encoder.h"
#include <bits/stdc++.h>
#define range(it, a, b) for (ll it = a; it < b; it++)
#define all(x) begin(x), end(x)
#define ll long long
#define ull unsigned long long
#define INF64 ((ll) 1 << 60)
#define INF32 (1 << 30)
#define mset multiset
#define uset unordered_set
#define umap unordered_map
#define pqueue priority_queue
#define ptr(A) shared_ptr<A>
using namespace std;
ll n;
vector<vector<ll>> adj, range;
vector<ll> euler;
void explore(ll i, ll from) {
range[i][0] = euler.size();
euler.push_back(i);
for (ll k : adj[i]) {
if (k == from)
continue;
explore(k, i);
}
range[i][1] = euler.size();
euler.push_back(i);
string pos = to_string(range[i][0]);
string ps = to_string(pos.size());
string sz = to_string(range[i][1] - range[i][0]);
Code(i, stoll(ps+pos+sz));
}
void Encode(int N, int A[], int B[]) {
n = N;
adj.resize(n);
range.resize(n, vector<ll> (2));
range(i, 0, n - 1) {
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
explore(0, 0);
}
#include "Device.h"
#include <bits/stdc++.h>
#define range(it, a, b) for (ll it = a; it < b; it++)
#define all(x) begin(x), end(x)
#define ll long long
#define ull unsigned long long
#define INF64 ((ll) 1 << 60)
#define INF32 (1 << 30)
#define mset multiset
#define uset unordered_set
#define umap unordered_map
#define pqueue priority_queue
#define ptr(A) shared_ptr<A>
using namespace std;
void InitDevice() { }
int Answer(long long S, long long T) {
string ss = to_string(S);
ll ps = stoll(ss.substr(0, 1));
ll sl = stoll(ss.substr(1, ps));
ll sr = sl + stoll(ss.substr(1 + ps, 6));
string ts = to_string(T);
ps = stoll(ts.substr(0, 1));
ll tl = stoll(ts.substr(1, ps));
ll tr = tl + stoll(ts.substr(1 + ps, 6));
// cout << ss << ' ' << ts << '\n';
// cout << sl << ' ' << sr << '\n';
// cout << tl << ' ' << tr << '\n';
ll ans;
if (sl < tl && tr < sr)
ans = 1;
else if (tl < sl && sr < tr)
ans = 0;
else
ans = 2;
// cout << ans << '\n';
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4892 KB |
Output is correct |
2 |
Correct |
0 ms |
4880 KB |
Output is correct |
3 |
Correct |
1 ms |
4880 KB |
Output is correct |
4 |
Correct |
1 ms |
4880 KB |
Output is correct |
5 |
Correct |
1 ms |
4880 KB |
Output is correct |
6 |
Correct |
1 ms |
4892 KB |
Output is correct |
7 |
Correct |
1 ms |
4896 KB |
Output is correct |
8 |
Correct |
2 ms |
4876 KB |
Output is correct |
9 |
Correct |
0 ms |
4880 KB |
Output is correct |
10 |
Correct |
1 ms |
4888 KB |
Output is correct |
11 |
Correct |
1 ms |
4892 KB |
Output is correct |
12 |
Correct |
1 ms |
5280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
195 ms |
12508 KB |
Output is correct - L = 41106129 |
2 |
Correct |
163 ms |
12432 KB |
Output is correct - L = 41163105 |
3 |
Correct |
185 ms |
12456 KB |
Output is correct - L = 41216109 |
4 |
Correct |
163 ms |
12456 KB |
Output is correct - L = 41271125 |
5 |
Incorrect |
421 ms |
56256 KB |
Output isn't correct - L = 6198739105869 |
6 |
Halted |
0 ms |
0 KB |
- |