This repository has been archived by the owner on Aug 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ABC] Create 024/c but has not been solved #15
- Loading branch information
Showing
2 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# define FOR(i,a,b) for(int i=(a);i<(b);++i) | ||
# define REP(i,n) FOR(i,0,n) | ||
# include <iostream> | ||
# include <algorithm> | ||
# include <iterator> | ||
# include <cstdlib> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
|
||
int N, D, K; | ||
cin >> N >> D >> K; | ||
int L[D], R[D], S[K], T[K], step[K]; | ||
|
||
REP(i, D) { | ||
cin >> L[i] >> R[i]; | ||
} | ||
|
||
REP(i, K) { | ||
cin >> S[i] >> T[i]; | ||
} | ||
|
||
REP(i, D) { | ||
|
||
// それぞれの民族について | ||
REP(j, K) { | ||
|
||
// 目的地にいない場合 | ||
if (S[j] != T[j]) { | ||
// できるだけ近くに行く | ||
|
||
// 移動しきれる | ||
if (L[i] <= T[j] && T[j] <= R[i]) { | ||
S[j] = T[j]; | ||
|
||
// 移動しきれない | ||
} else { | ||
step[j]++; | ||
|
||
// L or R | ||
if (abs(T[j] - L[i]) < abs(T[j] - R[i])){ | ||
S[j] = L[i]; | ||
} else { | ||
S[j] = R[i]; | ||
} | ||
|
||
} | ||
|
||
} | ||
} | ||
|
||
// みんな移動終了していたら終わり | ||
bool flag = true; | ||
REP(i, D) { | ||
if (S[i] != T[i]) { | ||
flag = false; | ||
break; | ||
} | ||
} | ||
|
||
REP(i, D) { | ||
cout << i << ' ' << S[i] << ' ' << T[i] << endl; | ||
} | ||
|
||
if (flag) { | ||
cout << i+1 << endl; | ||
return 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
N, D, K = map(int, input().split()) | ||
L = list() | ||
R = list() | ||
S = list() | ||
T = list() | ||
ans = list(0 for _ in range(K)) | ||
|
||
for d in range(D): | ||
l, r = map(int, input().split()) | ||
L.append(l) | ||
R.append(r) | ||
|
||
for k in range(K): | ||
s, t = map(int, input().split()) | ||
S.append(s) | ||
T.append(t) | ||
|
||
|
||
# for each stage | ||
for d in range(D): | ||
|
||
print(S) | ||
print(T) | ||
|
||
|
||
# for each people | ||
for k in range(K): | ||
|
||
if (S[k] == T[k]): | ||
continue | ||
|
||
if (L[d] <= T[k] and T[k] <= R[d]): | ||
S[k] = T[k] | ||
ans[k] += 1 | ||
|
||
elif (abs(T[k] - L[d]) < abs(T[k] - R[d])): | ||
S[k] = L[d] | ||
ans[k] += 1 | ||
|
||
elif (abs(T[k] - L[d]) > abs(T[k] - R[d])): | ||
S[k] = R[d] | ||
ans[k] += 1 | ||
|
||
print(ans) |