# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
115251 | gs14004 | World of Tank (innopolis2018_final_E) | C++17 | 102 ms | 19688 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 1000005;
vector<int> v[2];
bool vis[MAXN][2];
bool trk[MAXN][2];
int dp[MAXN][2];
int n, t;
bool findCut(){
for(auto &i : v[0]) vis[i][0] = 1;
for(auto &i : v[1]) vis[i][1] = 1;
dp[0][1] = -2e9;
for(int i=1; i<=n; i++){
for(int j=0; j<2; j++){
if(!vis[i-1][j] && dp[i-1][j] < min(dp[i-1][j^1], t)){
dp[i][j] = min(dp[i-1][j^1], t) + 1;
trk[i][j] = 1;
}
else{
dp[i][j] = dp[i-1][j] + 1;
}
if(vis[i][j]){
dp[i][j] -= t;
if(dp[i][j] <= 0) dp[i][j] = -2e9;
}
}
}
return max(dp[n][0], dp[n][1]) >= 0;
}
void trace(){
int pos = 0;
if(dp[n][0] < 0) pos = 1;
vector<pi> boom;
vector<int> trans;
for(int i=n; i; i--){
if(vis[i][pos]){
int where = i - dp[i][pos];
where = max(where, 1);
boom.emplace_back(where, pos + 1);
dp[i][pos] += t;
}
if(trk[i][pos]){
pos ^= 1;
trans.push_back(i - 1);
}
}
assert(pos == 0);
reverse(trans.begin(), trans.end());
reverse(boom.begin(), boom.end());
cout << trans.size() << endl;
for(auto &i : trans) printf("%d ", i);
cout << endl << boom.size() << endl;
for(auto &i : boom) printf("%d %d\n", i.first, i.second);
}
int main(){
int t0, t1;
scanf("%d %d %d %d",&n,&t0,&t1,&t);
assert(n <= 1000000);
v[0].resize(t0);
v[1].resize(t1);
for(int i=0; i<2; i++){
for(auto &j : v[i]){
scanf("%d",&j);
}
}
if(!findCut()){
puts("No");
return 0;
}
puts("Yes");
trace();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |