結果
| 問題 |
No.1226 I hate Robot Arms
|
| コンテスト | |
| ユーザー |
pengin_2000
|
| 提出日時 | 2020-09-12 00:34:09 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,144 bytes |
| コンパイル時間 | 443 ms |
| コンパイル使用メモリ | 31,344 KB |
| 実行使用メモリ | 7,680 KB |
| 最終ジャッジ日時 | 2025-01-01 23:23:39 |
| 合計ジャッジ時間 | 21,424 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | WA * 20 RE * 8 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%d %d", &n, &q);
| ^~~~~~~~~~~~~~~~~~~~~~
main.c:12:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d %d", &t[i], &ind[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:15:25: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%lf", &nx[i]);
| ^~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<math.h>
int main()
{
int n, q;
scanf("%d %d", &n, &q);
int i, j, k;
int t[100005], ind[100005];
double nx[100005];
for (i = 0; i < q; i++)
{
scanf("%d %d", &t[i], &ind[i]);
if (t[i] < 2)
{
scanf("%lf", &nx[i]);
ind[i]--;
}
}
double length[100005], theta[100005], st[100005];
for (i = 0; i < n; i++)
{
length[i] = 1.0;
theta[i] = 0.0;
st[i] = 0.0;
}
int sq = 0;
while (sq * sq < n)
sq++;
double x[100005], y[100005];
x[0] = y[0] = 0.0;
for (i = 0; i < n; i++)
{
x[i + 1] = x[i] + length[i];
y[i + 1] = 0;
}
double xx, yy, ds, r, s, dx, dy, dl;
for (i = 0; i < q; i++)
{
if (t[i] == 0)
{
ds = nx[i] * acos(-1) / 180.0 - theta[ind[i]];
theta[ind[i]] = nx[i] * acos(-1) / 180.0;
if (ind[i] > 0)
st[ind[i]] = st[ind[i] - 1] + theta[ind[i]];
else
st[0] = theta[0];
j = 0;
while (j + sq <= ind[i])
j += sq;
k = j + sq;
for (; j <= k; j++)
{
x[j + 1] = x[j] + length[j] * cos(st[j]);
y[j + 1] = y[j] + length[j] * sin(st[j]);
st[j + 1] = st[j] + theta[j + 1];
}
for (j = k + sq; j <= n; j += sq)
{
dx = x[j] - x[ind[i]];
dy = y[j] - y[ind[i]];
r = sqrt(dx * dx + dy * dy);
s = acos(dx / r);
if (dy < 0)
s *= -1;
s += ds;
x[j] = x[ind[i]] + r * cos(s);
y[j] = y[ind[i]] + r * sin(s);
st[j] += ds;
}
}
else if (t[i] == 1)
{
dl = nx[i] - length[ind[i]];
length[ind[i]] = nx[i];
j = 0;
while (j + sq <= ind[i])
j += sq;
k = j + sq;
for (; j <= k; j++)
{
x[j + 1] = x[j] + length[j] * cos(st[j]);
y[j + 1] = y[j] + length[j] * sin(st[j]);
st[j + 1] = st[j] + theta[j + 1];
}
dx = dl * cos(st[ind[i]]);
dy = dl * sin(st[ind[i]]);
for (j = k + sq; j <= n; j += sq)
{
x[j] += dx;
y[j] += dy;
}
}
else
{
j = 0;
while (j + sq <= ind[i])
j += sq;
k = j + sq;
for (; j < k; j++)
{
x[j + 1] = x[j] + length[j] * cos(st[j]);
y[j + 1] = y[j] + length[j] * sin(st[j]);
st[j + 1] = st[j] + theta[j + 1];
}
printf("%.20lf %.20lf\n", x[ind[i]], y[ind[i]]);
}
}
return 0;
}
pengin_2000