結果
| 問題 |
No.55 正方形を描くだけの簡単なお仕事です。
|
| コンテスト | |
| ユーザー |
alpha_virginis
|
| 提出日時 | 2016-02-25 00:22:07 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,471 bytes |
| コンパイル時間 | 618 ms |
| コンパイル使用メモリ | 66,716 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-14 13:53:33 |
| 合計ジャッジ時間 | 1,297 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:34:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
34 | scanf("%d %d", &p[0].x, &p[0].y);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:35:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
35 | scanf("%d %d", &p[1].x, &p[1].y);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:36:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
36 | scanf("%d %d", &p[2].x, &p[2].y);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
template<typename T>
class Vector2 {
public:
Vector2(){}
Vector2(T x_, T y_) : x(x_), y(y_) {}
T Norm2();
T x, y;
};
template<typename T> Vector2<T> operator + (const Vector2<T>& left, const Vector2<T>& right) {
return Vector2<T>(left.x + right.x, left.y + right.y);
}
template<typename T> Vector2<T> operator - (const Vector2<T>& left, const Vector2<T>& right) {
return Vector2<T>(left.x - right.x, left.y - right.y);
}
template<typename T>
T Vector2<T>::Norm2() {
return x * x + y * y;
}
int main() {
Vector2<int> p[3];
scanf("%d %d", &p[0].x, &p[0].y);
scanf("%d %d", &p[1].x, &p[1].y);
scanf("%d %d", &p[2].x, &p[2].y);
Vector2<int> v[3][3];
for(int i = 0; i < 3; ++i) {
for(int j = 0; j < 3; ++j) {
v[i][j] = p[j] - p[i];
}
}
Vector2<int> res;
bool exist = false;
if( v[0][1].Norm2() == v[0][2].Norm2() and v[0][1].Norm2() * 2 == v[1][2].Norm2() ) {
res = p[2] + p[1] - p[0]; exist = true;
}
if( v[1][0].Norm2() == v[1][2].Norm2() and v[1][0].Norm2() * 2 == v[0][2].Norm2() ) {
res = p[2] + p[0] - p[1]; exist = true;
}
if( v[2][0].Norm2() == v[2][1].Norm2() and v[2][0].Norm2() * 2 == v[0][1].Norm2() ) {
res = p[1] + p[0] - p[2]; exist = true;
}
if( exist ) {
printf("%d %d\n", res.x, res.y);
}
else {
printf("-1\n");
}
return 0;
}
alpha_virginis