QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#300514#5473. Move One CoinNYCU_CartesianTreeCompile Error//C++204.9kb2024-01-08 13:34:322024-01-08 13:34:32

Judging History

你现在查看的是最新测评结果

  • [2024-01-08 13:34:32]
  • 评测
  • [2024-01-08 13:34:32]
  • 提交

answer

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

#define int long long 
#define F first 
#define S second 
#define pb push_back 

int x1=-1,y1=-1,x2=-1,y2=-1;
int g1=-1,h1=-1,g2=-1,h2=-1;
int n1,m1;int n2,m2;
int total=0;
vector<vector<char>>a(505,vector<char>(505)),tot(505,vector<char>(505));
map<pair<int,int>,int>cnt;

void gan(vector<vector<char>>now){
    x2=-1,y2=-1,g2=-1,h2=-1;
    for(int i=0;i<n2;i++) for(int j=0;j<m2;j++){
        if(x2!=-1&&g2==-1&&now[i][j]=='o') g2=i,h2=j;
        if(x2==-1&&now[i][j]=='o') x2=i,y2=j;
    }
}

void rotate(vector<vector<char>>&b){
    map<pair<int,int>,int>tt;
    for(int i=0;i<n2;i++){
        for(int j=0;j<m2;j++){
            tot[m2-j-1][i]=b[i][j];
            // cerr<<m2-j-1<<" "<<i<<" "<<i<<" "<<j<<"\n";
            if(tot[m2-j-1][i]=='o') tt[{m2-j-1,i}]=1;
        }
    }
    // for(int i=0;i<n2;i++) {for(int j=0;j<m2;j++) cout<<tot[i][j]<<" ";cout<<"\n";}
    cnt=tt;

    b=tot;
    swap(n2,m2);
    gan(b);
}


bool check(){
    int d1=x2-x1,d2=y2-y1;
 
    set<pair<int,int>>fi;
    int u=0;
    pair<int,int>w1;
    for(int i=0;i<n1;i++){
        for(int j=0;j<m1;j++){
            int p,q;
            if(a[i][j]=='x') continue;
 
            if(!cnt.count({i+d1,j+d2})){
                u++;
                w1={j,i};
            }
            else fi.insert({i+d1,j+d2});
        }
    }
    // cerr<<"1\n";
    // cerr<<d1<<" "<<d2<<"d1,d2\n"<<fi.size()<<"\n";
    
    if(fi.size()==total-1){
        for(auto y:cnt){
            if(!fi.count(y.F)){
                cout<<w1.F<<" "<<w1.S<<"\n";
                cout<<y.F.S-d2<<" "<<y.F.F-d1<<"\n";
                return 1;
            }
        }
    }
    fi.clear();u=0;
 
    d1=g2-x1,d2=h2-y1;
 
    for(int i=0;i<n1;i++){
        for(int j=0;j<m1;j++){
            int p,q;
            if(a[i][j]=='x') continue;
 
            if(!cnt.count({i+d1,j+d2})){
                u++;
                w1={j,i};
            }
            else fi.insert({i+d1,j+d2});
        }
    }
    
    if(fi.size()==total-1){
        for(auto y:cnt){
            if(!fi.count(y.F)){
                cout<<w1.F<<" "<<w1.S<<"\n";
                cout<<y.F.S-d2<<" "<<y.F.F-d1<<"\n";
                return 1;
            }
        }
    }
    fi.clear();u=0;
 
    d1=x2-g1,d2=y2-h1;
 
    // cerr<<g1<<" "<<g2<<"\n";
    // cerr<<d1<<" "<<d2<<"d1d2\n";

    for(int i=0;i<n1;i++){
        for(int j=0;j<m1;j++){
            int p,q;
            if(a[i][j]=='x') continue;
 
            if(!cnt.count({i+d1,j+d2})){
                u++;
                w1={j,i};
            }
            else fi.insert({i+d1,j+d2});
        }
    }
    
    if(fi.size()==total-1){
        for(auto y:cnt){
            if(!fi.count(y.F)){
                cout<<w1.F<<" "<<w1.S<<"\n";
                cout<<y.F.S-d2<<" "<<y.F.F-d1<<"\n";
                return 1;
            }
        }
    }
    fi.clear();u=0;
 
    d1=g2-g1,d2=h2-h1;
 
    for(int i=0;i<n1;i++){
        for(int j=0;j<m1;j++){
            int p,q;
            if(a[i][j]=='x') continue;
 
            if(!cnt.count({i+d1,j+d2})){
                u++;
                w1={j,i};
            }
            else fi.insert({i+d1,j+d2});
        }
    }
    
    if(fi.size()==total-1){
        for(auto y:cnt){
            if(!fi.count(y.F)){
                cout<<w1.F<<" "<<w1.S<<"\n";
                cout<<y.F.S-d2<<" "<<y.F.F-d1<<"\n";
                return 1;
            }
        }
    }
    return 0;
}

void solve(){
    cin>>n1>>m1;

    for(int i=0;i<n1;i++) for(int j=0;j<m1;j++){
        cin>>a[i][j];
        if(a[i][j]=='o') total++;
        if(x1!=-1&&g1==-1&&a[i][j]=='o') g1=i,h1=j;
        if(x1==-1&&a[i][j]=='o') x1=i,y1=j;
    }


    cin>>n2>>m2;
    vector<vector<char>>b(n2+1,vector<char>(m2+1));
    for(int i=0;i<n2;i++) for(int j=0;j<m2;j++){
        cin>>b[i][j];
        if(b[i][j]=='o')
        cnt[{i,j}]=1;
        if(x2!=-1&&g2==-1&&b[i][j]=='o') g2=i,h2=j;
        if(x2==-1&&b[i][j]=='o') x2=i,y2=j;
    }

    // cerr<<x2<<" "<<y2<<" "<<g2<<" "<<h2<<"\n";

    if(check()) return;
    rotate(b);

    // for(int i=0;i<n2;i++){for(int j=0;j<m2;j++) cout<<b[i][j]<<" ";cout<<"\n";}

    // cout<<x2<<" "<<y2<<" "<<g2<<" "<<h2<<"\n";

    if(check()) return;
    // cerr<<"1\n";
    rotate(b);
    // for(int i=0;i<n2;i++){for(int j=0;j<m2;j++) cout<<b[i][j]<<" ";cout<<"\n";}
    if(check()) return;
    rotate(b);
    // for(int i=0;i<n2;i++){for(int j=0;j<m2;j++) cout<<b[i][j]<<" ";cout<<"\n";}
    if(check()) return;
    rotate(b);
    // for(int i=0;i<n2;i++){for(int j=0;j<m2;j++) cout<<b[i][j]<<" ";cout<<"\n";}
    if(check()) return;
    // cout<<y1<<" "<<x1<<"\n"<<y1<<" "<<x1<<"\n";
}

signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
    solve();
    return 0;
}

详细

answer.code:9:11: error: ‘long long int y1’ redeclared as different kind of entity
    9 | int x1=-1,y1=-1,x2=-1,y2=-1;
      |           ^~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:571,
                 from /usr/include/c++/11/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:33,
                 from answer.code:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:221:1: note: previous declaration ‘double y1(double)’
  221 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
answer.code: In function ‘bool check()’:
answer.code:43:23: error: invalid operands of types ‘long long int’ and ‘double(double) noexcept’ to binary ‘operator-’
   43 |     int d1=x2-x1,d2=y2-y1;
      |                     ~~^~~
      |                     |  |
      |                     |  double(double) noexcept
      |                     long long int
answer.code:74:19: error: invalid operands of types ‘long long int’ and ‘double(double) noexcept’ to binary ‘operator-’
   74 |     d1=g2-x1,d2=h2-y1;
      |                 ~~^~~
      |                 |  |
      |                 |  double(double) noexcept
      |                 long long int
answer.code: In function ‘void solve()’:
answer.code:163:41: error: assignment of function ‘double y1(double)’
  163 |         if(x1==-1&&a[i][j]=='o') x1=i,y1=j;
      |                                       ~~^~