結果

問題 No.471 直列回転機
ユーザー koyumeishikoyumeishi
提出日時 2016-12-07 18:28:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,056 bytes
コンパイル時間 1,440 ms
コンパイル使用メモリ 120,384 KB
実行使用メモリ 39,084 KB
最終ジャッジ日時 2023-09-23 11:51:48
合計ジャッジ時間 13,518 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main(int, char**)’ 内:
main.cpp:57:13: 警告: narrowing conversion of ‘round(cos(((PI * (double)r.operator[](size_type)((std::vector<long long int, std::allocator<long long int> >::size_type)i)) / 1.8e+2)))’ from ‘double’ to ‘long long int’ [-Wnarrowing]
   57 |       {round(cos(PI*r[i]/180.0)), round(-sin(PI*r[i]/180.0)), 0},
      |        ~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp:57:13: 警告: narrowing conversion of ‘round(cos(((PI * (double)r.operator[](size_type)((std::vector<long long int, std::allocator<long long int> >::size_type)i)) / 1.8e+2)))’ from ‘double’ to ‘long long int’ [-Wnarrowing]
main.cpp:57:40: 警告: narrowing conversion of ‘round((- sin(((PI * (double)r.operator[](size_type)((std::vector<long long int, std::allocator<long long int> >::size_type)i)) / 1.8e+2))))’ from ‘double’ to ‘long long int’ [-Wnarrowing]
   57 |       {round(cos(PI*r[i]/180.0)), round(-sin(PI*r[i]/180.0)), 0},
      |                                   ~~~~~^~~~~~~~~~~~~~~~~~~~~
main.cpp:57:40: 警告: narrowing conversion of ‘round((- sin(((PI * (double)r.operator[](size_type)((std::vector<long long int, std::allocator<long long int> >::size_type)i)) / 1.8e+2))))’ from ‘double’ to ‘long long int’ [-Wnarrowing]
main.cpp:58:13: 警告: narrowing conversion of ‘round(sin(((PI * (double)r.operator[](size_type)((std::vector<long long int, std::allocator<long long int> >::size_type)i)) / 1.8e+2)))’ from ‘double’ to ‘long long int’ [-Wnarrowing]
   58 |       {round(sin(PI*r[i]/180.0)), round( cos(PI*r[i]/180.0)), 0},
      |        ~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp:58:13: 警告: narrowing conversion of ‘round(sin(((PI * (double)r.operator[](size_type)((std::vector<long long int, std::allocator<long long int> >::size_type)i)) / 1.8e+2)))’ from ‘double’ to ‘long long int’ [-Wnarrowing]
main.cpp:58:40: 警告: narrowing conversion of ‘round(cos(((PI * (double)r.operator[](size_type)

ソースコード

diff #

#include <complex>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <functional>
#include <random>
#include <ctime>
#include "assert.h"

using namespace std;

//[n*p] * [p*m] => [n*m]
template<class T>
vector< vector<T> > multmat(const vector<vector<T> > &A, const vector<vector<T>> &B, int n, int p, int m){
  vector<vector<T> > C(n, vector<T>(m,0));
  for(int i=0; i<n; i++){
    for(int k=0; k<p; k++){
      for(int j=0; j<m; j++){
        C[i][j] += A[i][k] * B[k][j];
        //C[i][j] %= mod;
      }
    }
  }
  return C;
}

double PI = acos(-1.0);

int main(int argc, char* argv[]){
  int n;
  cin >> n;
  vector<long long> ox(n), oy(n), r(n);

  vector<vector<vector<long long>>> W(n);
  for(int i=0; i<n; i++){
    cin >> ox[i] >> oy[i] >> r[i];

    vector<vector<long long>> shift0 = {
      {1,0,-ox[i]},
      {0,1,-oy[i]},
      {0,0,1}
    };
    vector<vector<long long>> shift1 = {
      {1,0,ox[i]},
      {0,1,oy[i]},
      {0,0,1}
    };

    vector<vector<long long>> rot = {
      {round(cos(PI*r[i]/180.0)), round(-sin(PI*r[i]/180.0)), 0},
      {round(sin(PI*r[i]/180.0)), round( cos(PI*r[i]/180.0)), 0},
      {0,0, 1}
    };

    vector<vector<long long>> tmp = multmat(rot, shift0, 3,3,3);
    W[i] = multmat(shift1, tmp, 3,3,3);
  }

  vector<vector<long long>> A = {
    {1,0,0},
    {0,1,0},
    {0,0,1}
  };

  for(int i=0; i<n; i++){
    vector<vector<long long>> tmp = multmat(W[i], A, 3,3,3);
    A = tmp;
  }

  int m;
  cin >> m;
  vector<long long> px(m), py(m);
  for(int i=0; i<m; i++){
    cin >> px[i] >> py[i];
  }

  for(int i=0; i<m; i++){
    vector<vector<long long>> ans = {
      {px[i]},
      {py[i]},
      {1}
    };
    // for(int j=0; j<n; j++){
    //   vector<vector<long long>> tmp = multmat( W[j], ans, 3,3,1 );
    //   ans = tmp;
    // }

    auto res = multmat(A, ans, 3,3,1);

    cout << res[0][0] << " " << res[1][0] << endl;
  }



  return 0;
}
0