QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#131728 | #4688. Window Manager | PetroTarnavskyi# | Compile Error | / | / | C++17 | 5.2kb | 2023-07-27 22:25:19 | 2023-07-27 22:25:21 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-07-27 22:25:21]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-07-27 22:25:19]
- 提交
answer
PetroTarnavskyi
Logout
QOJ.ac
QOJ
Contests
Category
Problems
Submissions
Hack!
Universal Cup
Search the problem set
ID Problem Submitter Result Time Memory Language File size Submit time Judge time
#131723 #4688. Window Manager PetroTarnavskyi# WA 1ms 3608kb C++17 4.9kb 2023-07-27 22:22:02 2023-07-27 22:22:05
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FILL(a, b) memset(a, b, sizeof(a))
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
const int INF = 1e9 + 47;
const int N = 1 << 9;
#define begin beg
#define end en
int maxCoord[2];
bool active[N];
int begin[N][2], end[N][2];
bool intersect(int i, int j, int t) {
return max(begin[i][t], begin[j][t]) <= min(end[i][t], end[j][t]);
}
bool intersect(int i, int j) {
FOR(t, 0, 2) {
if (!intersect(i, j, t)) {
return false;
}
}
return true;
}
int n = 0;
bool openWindow(int x, int y, int w, int h, int j) {
begin[n][0] = x;
begin[n][1] = y;
end[n][0] = x + w - 1;
end[n][1] = y + h - 1;
if (end[n][0] >= maxCoord[0] || end[n][1] >= maxCoord[1]) {
return false;
}
FOR(i, 0, n) {
if (i != j && active[i] && intersect(i, n)) {
return false;
}
}
return true;
}
int findWindow(int x, int y) {
FOR(i, 0, n) {
if (active[i] && begin[i][0] <= x && x <= end[i][0] && begin[i][1] <= y && y <= end[i][1]) {
return i;
}
}
return -1;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
FOR(i, 0, 2) {
cin >> maxCoord[i];
}
string s;
int command = 1;
int cntActive = 0;
while (cin >> s) {
if (s == "OPEN") {
int x, y, w, h;
cin >> x >> y >> w >> h;
active[n] = openWindow(x, y, w, h, -1);
if (!active[n]) {
cout << "Command " << command << ": OPEN - window does not fit\n";
}
else {
n++;
cntActive++;
}
}
else if (s == "CLOSE") {
int x, y;
cin >> x >> y;
int idx = findWindow(x, y);
if (idx == -1) {
cout << "Command " << command << ": CLOSE - no window at given position\n";
}
else {
active[idx] = false;
cntActive--;
}
}
else if (s == "RESIZE") {
int x, y, w, h;
cin >> x >> y >> w >> h;
int idx = findWindow(x, y);
if (idx == -1) {
cout << "Command " << command << ": RESIZE - no window at given position\n";
}
else if (!openWindow(begin[idx][0], begin[idx][1], w, h, idx)) {
cout << "Command " << command << ": RESIZE - window does not fit\n";
}
else {
end[idx][0] = begin[idx][0] + w - 1;
end[idx][1] = begin[idx][1] + h - 1;
}
}
else {
//cerr << "s = " << s << endl;
assert(s == "MOVE");
//cerr << "command MOVE\n";
int x, y, dx, dy;
cin >> x >> y >> dx >> dy;
int idx = findWindow(x, y);
if (idx == -1) {
cout << "Command " << command << ": MOVE - no window at given position\n";
}
else {
int t = dy != 0 ? 1 : 0;
int d = abs(dx + dy);
if (dx + dy < 0) {
FOR(i, 0, n) {
begin[i][t] = maxCoord[t] - 1 - begin[i][t];
end[i][t] = maxCoord[t] - 1 - end[i][t];
swap(begin[i][t], end[i][t]);
}
}
vector<int> vec, inVec(n, 0), mn(n, INF);
vec.push_back(idx);
inVec[idx] = 1;
int moved = 0;
//cerr << "idx = " << idx << endl;
while (true) {
int globalMn = INF, indexMn = -1;
FOR(i, 0, n) {
if (active[i] && !inVec[i] && intersect(idx, i, t ^ 1)) {
mn[i] = min(mn[i], begin[i][t] - end[idx][t] - 1);
assert(mn[i] >= 0);
if (mn[i] < d - moved && mn[i] < globalMn) {
globalMn = mn[i];
indexMn = i;
}
}
}
//cerr << "globalMn " << globalMn << endl;
//cerr << "indexMn " << indexMn << endl;
int maxEnd = -1;
for (int i : vec) {
maxEnd = max(maxEnd, end[i][t]);
}
int currentMove;
if (indexMn == -1) {
currentMove = min(d - moved, maxCoord[t] - 1 - maxEnd);
}
else {
currentMove = globalMn;
}
//cerr << "currentMove " << currentMove << endl;
for (int i: vec) {
begin[i][t] += currentMove;
end[i][t] += currentMove;
assert(end[i][t] < maxCoord[t]);
}
moved += currentMove;
FOR(i, 0, n) {
mn[i] -= currentMove;
}
if (indexMn == -1) {
break;
}
else {
idx = indexMn;
vec.push_back(idx);
inVec[idx] = 1;
}
}
if (dx + dy < 0) {
FOR(i, 0, n) {
begin[i][t] = maxCoord[t] - 1 - begin[i][t];
end[i][t] = maxCoord[t] - 1 - end[i][t];
swap(begin[i][t], end[i][t]);
}
}
if (moved < d) {
cout << "Command " << command << ": MOVE - moved " << moved << " instead of " << d << "\n";
}
}
}
command++;
}
cout << cntActive << " window(s):\n";
FOR(i, 0, n) {
if (active[i]) {
cout << begin[i][0] << " " << begin[i][1] << " " << end[i][0] - begin[i][0] + 1 << " " << end[i][1] - begin[i][1] + 1 << "\n";
}
}
return 0;
}
詳細信息
answer.code:13:9: error: "#" is not a valid filename 13 | #131723 #4688. Window Manager PetroTarnavskyi# WA 1ms 3608kb C++17 4.9kb 2023-07-27 22:22:02 2023-07-27 22:22:05 | ^ answer.code:1:1: error: ‘PetroTarnavskyi’ does not name a type 1 | PetroTarnavskyi | ^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/cmath:43, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41, from answer.code:15: /usr/include/c++/11/ext/type_traits.h:162:35: error: ‘bool __gnu_cxx::__is_null_pointer’ redeclared as different kind of entity 162 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/11/ext/type_traits.h:157:5: note: previous declaration ‘template<class _Type> bool __gnu_cxx::__is_null_pointer(_Type)’ 157 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/11/ext/type_traits.h:162:26: error: ‘nullptr_t’ is not a member of ‘std’ 162 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/11/bits/move.h:57, from /usr/include/c++/11/bits/stl_pair.h:59, from /usr/include/c++/11/bits/stl_algobase.h:64, from /usr/include/c++/11/bits/specfun.h:45, from /usr/include/c++/11/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41, from answer.code:15: /usr/include/c++/11/type_traits:405:26: error: ‘std::size_t’ has not been declared 405 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/11/type_traits:406:25: error: ‘_Size’ was not declared in this scope 406 | struct is_array<_Tp[_Size]> | ^~~~~ /usr/include/c++/11/type_traits:406:31: error: template argument 1 is invalid 406 | struct is_array<_Tp[_Size]> | ^ /usr/include/c++/11/type_traits:511:42: error: ‘nullptr_t’ is not a member of ‘std’ 511 | struct __is_null_pointer_helper<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/11/type_traits:511:51: error: template argument 1 is invalid 511 | struct __is_null_pointer_helper<std::nullptr_t> | ^ /usr/include/c++/11/type_traits:1311:37: error: ‘size_t’ is not a member of ‘std’; did you mean ‘size_t’? 1311 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ In file included from /usr/include/stdlib.h:31, from /usr/include/c++/11/bits/std_abs.h:38, from /usr/include/c++/11/cmath:47, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41, from answer.code:15: /usr/lib/gcc/x86_64-linux-gnu/11/include/stddef.h:209:23: note: ‘size_t’ declared here 209 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ In file included from /usr/include/c++/11/bits/move.h:57, from /usr/include/c++/11/bits/stl_pair.h:59, from /usr/include/c++/11/bits/stl_algobase.h:64, from /usr/include/c++/11/bits/specfun.h:45, from /usr/include/c++/11/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41, from answer.code:15: /usr/include/c++/11/type_traits:1311:57: error: template argument 1 is invalid 1311 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/11/type_traits:1311:57: note: invalid template non-type parameter /usr/include/c++/11/type_traits:1320:37: error: ‘size_t’ is not a member of ‘std’; did you mean ‘size_t’? 1320 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ In file included from /usr/include/stdlib.h:31, from /usr/include/c++/11/bits/std_abs.h:38, from /usr/include/c++/11/cmath:47, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41, from answer.code:15: /usr/lib/gcc/x86_64-linux-gnu/11/include/stddef.h:209:23: note: ‘size_t’ declared here 209 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ In file included from /usr/include/c++/11/bits/move.h:57, from /usr/include/c++/11/bits/stl_pair.h:59, from /usr/include/c++/11/bits/stl_algobase.h:64, from /usr/include/c++/11/bits/specfun.h:45, from /usr/include/c++/11/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41, from answer.code:15: /usr/include/c++/11/type_traits:1320:46: error: template argument 1 is invalid 1320 | : public integral_constant<std::size_t, 0> { }; | ...