QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#386875#5112. Where Am I?Energy_is_not_over#Compile Error//C++173.4kb2024-04-11 20:55:512024-04-11 20:55:52

Judging History

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

  • [2024-04-11 20:55:52]
  • 评测
  • [2024-04-11 20:55:51]
  • 提交

answer

//
// Stvoreno ENERGom o 11.04.24. 14:31:54
//

#include <bits/stdc++.h>

#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define F first
#define fir first
#define S second
#define sec second
#define mp make_pair
#define MP make_pair
#define pb push_back
#define PB push_back

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

#ifdef Energy
#define DEBUG for (int _____DEBUG=1;_____DEBUG;_____DEBUG=0)

template<class ...Ts>
auto &PRNT(Ts ...ts) { return ((cerr << ts << " "), ...); }

#define LOG(...) PRNT(#__VA_ARGS__" ::",__VA_ARGS__)<<endl
#else
#define DEBUG while (0)
#define LOG(...)
#endif

const int max_n = 1e3+10, inf = 1000111222;

const int max_k=10;

int n,m,k;
bool f[max_k][max_n][max_n];
int dx[max_k];
int dy[max_k];

int known[max_n][max_n];
bool used[max_n][max_n];

inline bool ok_pos(int x,int y)
{
    return 0<=x && x<n && 0<=y && y<m;
}

void dfs(int x,int y)
{
    assert(known[x][y]!=-1);
    used[x][y]=1;

    for (int i=0;i<k;i++){
        if (ok_pos(x+dx[i],y+dy[i]) && known[x][y]==0 && known[x+dx[i]][y+dy[i]]==-1 && !f[i][x+dx[i]][y+dy[i]]){
            known[x+dx[i]][y+dy[i]]=0;
            dfs(x+dx[i],y+dy[i]);
        }
        if (ok_pos(x-dx[i],y-dy[i]) && known[x][y]==1 && known[x-dx[i]][y-dy[i]]==-1 && !f[i][x][y]){
            known[x-dx[i]][y-dy[i]]=1;
            dfs(x-dx[i],y-dy[i]);
        }
    }
}

int main() {
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>n>>m>>k;
    for (int i=0;i<k;i++){
        cin>>dx[i]>>dy[i];
//        dx[i]*=-1;
//        dy[i]*=-1;
        int s;
        cin>>s;
        while (s--){
            int a,b;
            cin>>a>>b;
            a--;
            b--;

            f[i][a][b]=1;
        }
    }
    memset(known,-1,sizeof(known));
    for (int i=0;i<k;i++){
        for (int x=0;x<n;x++){
            for (int y=0;y<m;y++){
                if (ok_pos(x+dx[i],y+dy[i])){
                    if (f[i][x+dx[i]][y+dy[i]]){
                        known[x+dx[i]][y+dy[i]]=1;
                        known[x][y]=0;
                    }
                }
                if (f[i][x][y]){
                    known[x][y]=1;
                    if (ok_pos(x-dx[i],y-dy[i])){
                        known[x-dx[i]][y-dy[i]]=0;
                    }
                }

                if (!f[i][x][y] && !ok_pos(x-dx[i],y-dy[i])){
                    known[x][y]=0;
                }
            }
        }
    }
    for (int x=0;x<n;x++){
        for (int y=0;y<m;y++){
            if (known[x][y]!=-1 && !used[x][y]){
                dfs(x,y);
            }
        }
    }
    for (int iter=0;iter<2;iter++){
        for (int y=0;y<m;y++){
            for (int x=0;x<n;x++){
                int res=(known[x][y]==-1 ? iter : known[x][y]);
                assert(res==0 || res==1);
                cout<<(res==0?'.':'#');
            }
            cout<<"\n";
        }
        cout<<"\n";
    }

    exit(0);
}


/home/icpc/workspace/WF/WF21/cmake-build-debug/WF21
6 6 3
1 1 3 3 1 1 3 2 2
0 2 6 3 1 1 3 2 2 6 4 5 3 4 2
1 -1 4 1 3 2 4 3 5 4 6
..#...
.#.#..
#.#.#.
.#.#.#
..#...
......

..#...
.#.#..
#.#.#.
.#.#.#
..#...
......


Process finished with exit code 0

详细

answer.code:143:3: error: stray ‘#’ in program
  143 | ..#...
      |   ^
answer.code:144:2: error: stray ‘#’ in program
  144 | .#.#..
      |  ^
answer.code:144:4: error: stray ‘#’ in program
  144 | .#.#..
      |    ^
answer.code:145:2: error: invalid preprocessing directive #.
  145 | #.#.#.
      |  ^
answer.code:146:2: error: stray ‘#’ in program
  146 | .#.#.#
      |  ^
answer.code:146:4: error: stray ‘#’ in program
  146 | .#.#.#
      |    ^
answer.code:146:6: error: stray ‘#’ in program
  146 | .#.#.#
      |      ^
answer.code:147:3: error: stray ‘#’ in program
  147 | ..#...
      |   ^
answer.code:150:3: error: stray ‘#’ in program
  150 | ..#...
      |   ^
answer.code:151:2: error: stray ‘#’ in program
  151 | .#.#..
      |  ^
answer.code:151:4: error: stray ‘#’ in program
  151 | .#.#..
      |    ^
answer.code:152:2: error: invalid preprocessing directive #.
  152 | #.#.#.
      |  ^
answer.code:153:2: error: stray ‘#’ in program
  153 | .#.#.#
      |  ^
answer.code:153:4: error: stray ‘#’ in program
  153 | .#.#.#
      |    ^
answer.code:153:6: error: stray ‘#’ in program
  153 | .#.#.#
      |      ^
answer.code:154:3: error: stray ‘#’ in program
  154 | ..#...
      |   ^
answer.code:138:1: error: expected unqualified-id before ‘/’ token
  138 | /home/icpc/workspace/WF/WF21/cmake-build-debug/WF21
      | ^