結果
| 問題 |
No.675 ドットちゃんたち
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-01 08:39:36 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 175 ms / 2,000 ms |
| コード長 | 2,108 bytes |
| コンパイル時間 | 3,584 ms |
| コンパイル使用メモリ | 205,600 KB |
| 最終ジャッジ日時 | 2025-01-12 12:18:12 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 8 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:60:27: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
60 | int n,x0,y0; scanf("%d%d%d",&n,&x0,&y0);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
main.cpp:64:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
64 | int type; scanf("%d",&type);
| ~~~~~^~~~~~~~~~~~
main.cpp:66:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
66 | int dx; scanf("%d",&dx);
| ~~~~~^~~~~~~~~~
main.cpp:72:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
72 | int dy; scanf("%d",&dy);
| ~~~~~^~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
template<class R>
class matrix{
vector<vector<R>> a;
public:
matrix(int n):a(n,vector<R>(n)){}
matrix(int m,int n):a(m,vector<R>(n)){}
matrix& operator+=(const matrix& A){
assert(h()==A.h() && w()==A.w());
int m=h(),n=w();
rep(i,m) rep(j,n) (*this)[i][j]+=A[i][j];
return *this;
}
matrix& operator-=(const matrix& A){
assert(h()==A.h() && w()==A.w());
int m=h(),n=w();
rep(i,m) rep(j,n) (*this)[i][j]-=A[i][j];
return *this;
}
matrix& operator*=(const matrix& A){
assert(w()==A.h());
int m=h(),n=w(),l=A.w();
matrix B(m,l);
rep(i,m) rep(j,l) rep(k,n) B[i][j]+=(*this)[i][k]*A[k][j];
swap(*this,B);
return *this;
}
matrix operator+(const matrix& A)const{ return matrix(*this)+=A; }
matrix operator-(const matrix& A)const{ return matrix(*this)-=A; }
matrix operator*(const matrix& A)const{ return matrix(*this)*=A; }
const vector<R>& operator[](int i)const{ return a[i]; }
vector<R>& operator[](int i){ return a[i]; }
vector<R> operator*(const vector<R>& v)const{
assert(w()==v.size());
int m=h(),n=w();
vector<R> res(m);
rep(i,m) rep(j,n) res[i]+=(*this)[i][j]*v[j];
return res;
}
int h()const{ return a.size(); }
int w()const{ return a.empty()?0:a[0].size(); }
static matrix identity(int n){
matrix I(n);
rep(i,n) I[i][i]=R{1};
return I;
}
};
int main(){
int n,x0,y0; scanf("%d%d%d",&n,&x0,&y0);
vector A(n,matrix<lint>(3));
vector B(n,matrix<lint>(3));
rep(i,n){
int type; scanf("%d",&type);
if(type==1){
int dx; scanf("%d",&dx);
rep(k,2) A[i][k][k]=B[i][k][k]=1;
A[i][0][2]=dx;
B[i][0][2]=-dx;
}
else if(type==2){
int dy; scanf("%d",&dy);
rep(k,2) A[i][k][k]=B[i][k][k]=1;
A[i][1][2]=dy;
B[i][1][2]=-dy;
}
else{
A[i][0][1]=1;
A[i][1][0]=-1;
B[i][0][1]=-1;
B[i][1][0]=1;
}
A[i][2][2]=1;
B[i][2][2]=1;
}
auto C=matrix<lint>::identity(3);
rep(i,n) C=A[i]*C;
rep(i,n){
auto v=C*vector<lint>{x0,y0,1};
printf("%lld %lld\n",v[0],v[1]);
C*=B[i];
}
return 0;
}