TopCoder

User's AC Ratio

66.7% (4/6)

Submission's AC Ratio

36.4% (4/11)

Tags

Description

對於輸入的兩個從原點出發的向量,如果要以最小的角度旋轉第一個向量來讓兩個向量指向同一個方向,那應該往哪個方向轉呢?

以下為會得到 WA 的參考解法,請用 $2$ 以內的編輯距離將這段程式碼改對吧!

#include <bits/stdc++.h>
using namespace std;

int cmp(int x, int y, int z)
{
    if (x < 0) return y;
    else if (x > 0) return z;
    else return 0;
}

#define int long long
const int CLOCKWISE = -1, PARALLEL = 0, COUNTERCLOCKWISE = 1;
string output[] = { "clockwise", "parallel", "counterclockwise" };

main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int cross = a * d - b * c;
    int sign = cmp(cross, CLOCKWISE, COUNTERCLOCKWISE);
    cout << output[sign + 1] << '\n';
}

Input Format

輸入四個正整數 $a, b, c, d$ ,代表第一個向量是 $(a, b)$ 、第二個向量是 $(c, d)$ 。

  • $1\le a, b, c, d \le 10^ 9$

Output Format

如果兩個向量一開始就是平行的,輸出 parallel

否則若順時針轉所需的角度較小,輸出 clockwise

如果是逆時針轉所需的角度較小,輸出 counterclockwise

Sample Input 1

1 1000000 1000000 1

Sample Output 1

clockwise

Hints

Problem Source

IOICamp 2023 Day1 pB

Subtasks

No. Testdata Range Score
1 0~18 100

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 65536 1
1 1000 65536 65536 1
2 1000 65536 65536 1
3 1000 65536 65536 1
4 1000 65536 65536 1
5 1000 65536 65536 1
6 1000 65536 65536 1
7 1000 65536 65536 1
8 1000 65536 65536 1
9 1000 65536 65536 1
10 1000 65536 65536 1
11 1000 65536 65536 1
12 1000 65536 65536 1
13 1000 65536 65536 1
14 1000 65536 65536 1
15 1000 65536 65536 1
16 1000 65536 65536 1
17 1000 65536 65536 1
18 1000 65536 65536 1