제출 #93970

#제출 시각아이디문제언어결과실행 시간메모리
93970Noam527움직이는 개미 (IZhO12_ants)C++17
0 / 100
2 ms504 KiB
#include <bits/stdc++.h> #define CHECK cout << "ok" << endl #define finish(x) return cout << x << endl, 0 typedef long long ll; typedef long double ldb; const int md = 1e9 + 7, inf = 1e9 + 7; using namespace std; void debug(string names) { cout << '\n'; } template<typename A1, typename... A2> void debug(string names, A1 par, A2... left) { int pos = 0; for (; pos < names.size() && names[pos] != ' ' && names[pos] != ','; pos++) cout << names[pos]; cout << ": " << par << " "; while (pos < names.size() && (names[pos] == ' ' || names[pos] == ',')) { pos++; } names.erase(names.begin(), names.begin() + pos); debug(names, left...); } struct ant { int x, y, d, ind; ant() {} ant(int xx, int yy, int dd, int ii) { x = xx; y = yy; d = dd; ind = ii; } bool operator < (const ant &a) const { if (x != a.x) return x < a.x; return y < a.y; } void advance(int w, int h, int cnt) { if (d == 1 || d == 3) { cnt %= 2 * w; while (cnt--) { if (d == 1) x++; else x--; if (x == 0 || x == w) d ^= 2; } } else { cnt %= 2 * h; while (cnt--) { if (d == 2) y++; else y--; if (y == 0 || y == h) d ^= 6; } } } }; int w, h, k, T; vector<ant> V[102], H[102]; vector<ant> ans; int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> w >> h >> k >> T; ans.resize(k); for (int i = 0, par[3]; i < k; i++) { cin >> par[0] >> par[1] >> par[2]; if (par[1] & 1) H[par[1]].push_back(ant(par[0], par[1], par[2], i)); else V[par[0]].push_back(ant(par[0], par[1], par[2], i)); } vector<int> bef; for (int i = 0; i < 102; i++) { sort(V[i].begin(), V[i].end()); bef.resize(V[i].size()); for (int j = 0; j < bef.size(); j++) bef[j] = V[i][j].ind; for (auto &j : V[i]) j.advance(w, h, T); sort(V[i].begin(), V[i].end()); for (int j = 0; j < bef.size(); j++) ans[bef[j]] = V[i][j]; sort(H[i].begin(), H[i].end()); bef.resize(H[i].size()); for (int j = 0; j < bef.size(); j++) bef[j] = H[i][j].ind; for (auto &j : H[i]) j.advance(w, h, T); sort(H[i].begin(), H[i].end()); for (int j = 0; j < bef.size(); j++) ans[bef[j]] = H[i][j]; } for (const auto &i : ans) cout << i.x << " " << i.y << " " << i.d << '\n'; }

컴파일 시 표준 에러 (stderr) 메시지

ants.cpp: In function 'int main()':
ants.cpp:76:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < bef.size(); j++) bef[j] = V[i][j].ind;
                   ~~^~~~~~~~~~~~
ants.cpp:79:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < bef.size(); j++) ans[bef[j]] = V[i][j];
                   ~~^~~~~~~~~~~~
ants.cpp:83:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < bef.size(); j++) bef[j] = H[i][j].ind;
                   ~~^~~~~~~~~~~~
ants.cpp:86:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < bef.size(); j++) ans[bef[j]] = H[i][j];
                   ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...