# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
264738 |
2020-08-14T08:46:26 Z |
송준혁(#5083) |
Tram (CEOI13_tram) |
C++17 |
|
1000 ms |
1900 KB |
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
int N, M;
int X[1505], Y[1505];
int D[150505][2];
bool A[150505][2];
int main(){
char ch;
scanf("%d %d", &N, &M);
for (int m=1; m<=M; m++){
scanf(" %c", &ch);
if (ch == 'E'){
int a=-2*N, b=-2*N;
for (int i=1; i<=N; i++){
D[i][0]=D[i][1]=2*N;
if (A[i][0]) D[i][0] = 0, a=i;
if (A[i][1]) D[i][1] = 0, b=i;
D[i][0] = min(D[i][0], max(2, 2*(i-a)));
D[i][0] = min(D[i][0], max(2, 2*(i-b)+1));
D[i][1] = min(D[i][1], max(2, 2*(i-b)));
D[i][1] = min(D[i][1], max(2, 2*(i-a)+1));
}
a=b=3*N;
for (int i=N; i>0; i--){
if (A[i][0]) D[i][0] = 0, a=i;
if (A[i][1]) D[i][1] = 0, b=i;
D[i][0] = min(D[i][0], max(2, 2*(a-i)));
D[i][0] = min(D[i][0], max(2, 2*(b-i)+1));
D[i][1] = min(D[i][1], max(2, 2*(b-i)));
D[i][1] = min(D[i][1], max(2, 2*(a-i)+1));
}
int d=0, x, y;
for (int i=1; i<=N; i++){
if (D[i][0] > d) d=D[i][0], x=i, y=0;
if (D[i][1] > d) d=D[i][1], x=i, y=1;
}
X[m] = x, Y[m] = y;
A[x][y] = true;
printf("%d %d\n", x, y+1);
}
else{
int x;
scanf("%d", &x);
A[X[x]][Y[x]] = false;
}
}
return 0;
}
Compilation message
tram.cpp: In function 'int main()':
tram.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
15 | scanf("%d %d", &N, &M);
| ~~~~~^~~~~~~~~~~~~~~~~
tram.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
17 | scanf(" %c", &ch);
| ~~~~~^~~~~~~~~~~~
tram.cpp:49:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
49 | scanf("%d", &x);
| ~~~~~^~~~~~~~~~
tram.cpp:45:10: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
45 | printf("%d %d\n", x, y+1);
| ~~~~~~^~~~~~~~~~~~~~~~~~~
tram.cpp:43:9: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
43 | X[m] = x, Y[m] = y;
| ~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
364 KB |
Output is correct |
2 |
Correct |
3 ms |
364 KB |
Output is correct |
3 |
Correct |
24 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
364 KB |
Output is correct |
2 |
Correct |
4 ms |
364 KB |
Output is correct |
3 |
Correct |
31 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1083 ms |
1900 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
1772 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
475 ms |
620 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1081 ms |
1860 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |