結果
| 問題 |
No.675 ドットちゃんたち
|
| コンテスト | |
| ユーザー |
prog470
|
| 提出日時 | 2019-06-22 16:47:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,236 bytes |
| コンパイル時間 | 1,002 ms |
| コンパイル使用メモリ | 99,008 KB |
| 最終ジャッジ日時 | 2025-01-07 05:06:34 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 3 WA * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:96:21: warning: ‘ansx’ may be used uninitialized [-Wmaybe-uninitialized]
96 | cout<<ansx<<" "<<ansy<<endl;
| ^~~
main.cpp:77:13: note: ‘ansx’ was declared here
77 | int ansx, ansy;
| ^~~~
main.cpp:96:26: warning: ‘ansy’ may be used uninitialized [-Wmaybe-uninitialized]
96 | cout<<ansx<<" "<<ansy<<endl;
| ^~~~
main.cpp:77:19: note: ‘ansy’ was declared here
77 | int ansx, ansy;
| ^~~~
ソースコード
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n, N) for(ll i=(n);i<(N);i++)
#define RREP(i, n, N) for(ll i=(N-1);i>=(n);i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(), (v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
int N, Px, Py;
int cmd[100010][2];
int movex[100010];
int movey[100010];
int rd[100010];
int main() {
cin>>N>>Px>>Py;
REP(i,0,N){
cin>>cmd[i][0];
if(cmd[i][0] != 3) cin>>cmd[i][1];
}
int routeCount = 0;
REP(i,0,N){
if(cmd[i][0] == 3) routeCount++, rd[i] = 1;
if(i > 0) rd[i] += rd[i-1];
}
RREP(i,0,N){
if(cmd[i][0] == 3) {
routeCount--;
continue;
}
if(routeCount % 4 == 0){
if (cmd[i][0] == 1) movex[i] = cmd[i][1];
else movey[i] = cmd[i][1];
}else if(routeCount % 4 == 1) {
if (cmd[i][0] == 1) movey[i] = -cmd[i][1];
else movex[i] = cmd[i][1];
}else if(routeCount % 4 == 2) {
if (cmd[i][0] == 1) movex[i] = -cmd[i][1];
else movey[i] = -cmd[i][1];
}else if(routeCount % 4 == 3) {
if (cmd[i][0] == 1) movey[i] = cmd[i][1];
else movex[i] = -cmd[i][1];
}
}
RREP(i,0,N-1){
movex[i] += movex[i+1];
movey[i] += movey[i+1];
}
REP(i,0,N){
int x = Px + movex[i];
int y = Py + movey[i];
int ansx, ansy;
int r =rd[N-1] - rd[i];
if(cmd[i][0] == 3) r++;
if(r % 4 == 0){
ansx = x;
ansy = y;
}else if(r % 4 == 1) {
ansx = y;
ansy = -x;
}else if(r % 4 == 2) {
ansx = -x;
ansy = -y;
}else if(r % 4 == 3) {
ansx = -y;
ansy = x;
}
cout<<ansx<<" "<<ansy<<endl;
}
return 0;
}
prog470