Submission #68559
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { cin.tie(nullptr); ios_base::sync_with_stdio( false ); int n; cin >> n; vector< int > x(n), y(n), v1, v2; for ( int i = 0; i < n; ++i) { cin >> x[i] >> y[i]; v1.emplace_back(x[i] + y[i]); v2.emplace_back(x[i] - y[i]); } sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end()); auto f = [](vector< int > &v) -> long long { long long ret = 0, cnt = 1; for ( int i = 1; i < v.size(); ++i) { if (v[i - 1] == v[i]) { cnt++; } else { ret += cnt * (cnt - 1) / 2; cnt = 1; } } ret += cnt * (cnt - 1) / 2; return (ret); }; cout << f(v1) + f(v2) << '\n' ; return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 1525 - Counting Squares |
ユーザー名 | ei1903 |
投稿日時 | 2021-09-23 14:46:53 |
言語 | C++17 |
状態 | Accepted |
得点 | 3 |
ソースコード長 | 891 Byte |
最大実行時間 | 106 ms |
最大メモリ使用量 | 6432 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 3 / 3 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 35 ms | 600 KB |
1
|
in02.txt | AC | 14 ms | 428 KB |
1
|
in03.txt | AC | 18 ms | 508 KB |
1
|
in04.txt | AC | 23 ms | 464 KB |
1
|
in05.txt | AC | 20 ms | 416 KB |
1
|
in06.txt | AC | 20 ms | 632 KB |
1
|
in07.txt | AC | 23 ms | 512 KB |
1
|
in08.txt | AC | 22 ms | 584 KB |
1
|
in09.txt | AC | 19 ms | 512 KB |
1
|
in10.txt | AC | 20 ms | 568 KB |
1
|
in11.txt | AC | 20 ms | 516 KB |
1
|
in12.txt | AC | 21 ms | 592 KB |
1
|
in13.txt | AC | 23 ms | 648 KB |
1
|
in14.txt | AC | 23 ms | 720 KB |
1
|
in15.txt | AC | 19 ms | 628 KB |
1
|
in16.txt | AC | 59 ms | 3472 KB |
1
|
in17.txt | AC | 67 ms | 3712 KB |
1
|
in18.txt | AC | 51 ms | 2884 KB |
1
|
in19.txt | AC | 49 ms | 2364 KB |
1
|
in20.txt | AC | 35 ms | 1196 KB |
1
|
in21.txt | AC | 101 ms | 6172 KB |
1
|
in22.txt | AC | 100 ms | 6312 KB |
1
|
in23.txt | AC | 106 ms | 6196 KB |
1
|
in24.txt | AC | 106 ms | 6212 KB |
1
|
in25.txt | AC | 97 ms | 6220 KB |
1
|
in26.txt | AC | 101 ms | 6228 KB |
1
|
in27.txt | AC | 96 ms | 6236 KB |
1
|
in28.txt | AC | 78 ms | 6248 KB |
1
|
in29.txt | AC | 81 ms | 6392 KB |
1
|
in30.txt | AC | 91 ms | 6404 KB |
1
|
in31.txt | AC | 79 ms | 6408 KB |
1
|
in32.txt | AC | 89 ms | 6288 KB |
1
|
in33.txt | AC | 89 ms | 6432 KB |
1
|
in34.txt | AC | 86 ms | 6312 KB |
1
|
in35.txt | AC | 84 ms | 6200 KB |
1
|
in36.txt | AC | 82 ms | 6212 KB |
1
|
in37.txt | AC | 83 ms | 6220 KB |
1
|
in38.txt | AC | 73 ms | 6232 KB |
1
|
in39.txt | AC | 74 ms | 6244 KB |
1
|
in40.txt | AC | 85 ms | 6252 KB |
1
|
in41.txt | AC | 56 ms | 6264 KB |
1
|
sample.txt | AC | 15 ms | 664 KB |
1
|