답안 #732114

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
732114 2023-04-28T13:05:36 Z Trunkty Plus Minus (BOI17_plusminus) C++14
0 / 100
1 ms 212 KB
#include <bits/extc++.h>
using namespace std;
typedef long long ll;
#define int ll

int n,m,k,ans,mod=1e9+7;
map<int,vector<int>> row,col;

int dopow(int x, int y){
    if(y==0){
        return 1;
    }
    int z = dopow(x,y/2);
    if(y%2){
        return (((z*z)%mod)*x)%mod;
    }
    else{
        return (z*z)%mod;
    }
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> n >> m >> k;
    for(int i=1;i<=k;i++){
        char a;
        int b,c;
        cin >> a >> b >> c;
        if(a=='-'){
            row[b].push_back(c+1);
            col[c].push_back(b+1);
        }
        else{
            row[b].push_back(c);
            col[c].push_back(b);
        }
    }
    bool isrow=true,iscol=true;
    for(auto it=row.begin();it!=row.end();it++){
        int p = (it->second)[0];
        for(int i:(it->second)){
            if(i%2!=p%2){
                isrow = false;
            }
        }
    }
    for(auto it=col.begin();it!=col.end();it++){
        int p = (it->second)[0];
        for(int i:(it->second)){
            if(i%2!=p%2){
                iscol = false;
            }
        }
    }
    if(isrow and iscol){
        ans = dopow(2,n-row.size());
        ans += dopow(2,m-col.size());
        ans--;
        ans %= mod;
    }
    else if(isrow){
        ans = dopow(2,n-row.size());
    }
    else if(iscol){
        ans = dopow(2,m-col.size());
    }
    cout << ans << "\n";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -