Submission #40190

# Submission time Handle Problem Language Result Execution time Memory
40190 2018-01-29T11:46:27 Z krauch Ili (COI17_ili) C++14
Compilation error
0 ms 0 KB
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair < ll, int > PLI;


#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

#define fname ""

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 505;

int n, m, a[N], b[N];
bitset < N > bit[N];

int main() {
	//ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

	#ifdef krauch
        freopen("input.txt", "r", stdin);
    #else
        //freopen(fname".in", "r", stdin);
        //freopen(fname".out", "w", stdout);
    #endif

    scanf("%d %d\n", &n, &m);
    forn(i, 1, n) b[i] = -1;
    forn(i, 1, m) {
        char c;
        scanf("%c", &c);
        if (c == '?') a[i] = -1;
        else a[i] = c - '0';
    }
    scanf("\n");
    forn(i, 1, m) {
        char c;
        int x;
        scanf("%c%d ", &c, &x);
        if (c == 'x') {
            bit[i][x] = 1;
        }
        else {
            bit[i] |= bit[x];
        }
        scanf("%c%d\n", &c, &x);
        if (c == 'x') {
            bit[i][x] = 1;
        }
        else {
            bit[i] |= bit[x];
        }
        if (a[i] == 0) {
            forn(j, 1, n) if (bit[i][j] == 1) b[j] = 0;
        }
    }

    forn(l, 1, max(n, m) + 1);
        forn(i, 1, m) {
            int cnt = 0;
            forn(j, 1, n) if (bit[i][j] == 1) cnt += (b[j] == 0);
            if (cnt == bit[i].count()) a[i] = 0;
        }

        forn(i, 1, m) {
            int cnt = 0;
            forn(j, 1, n) if (bit[i][j] == 1) cnt += (b[j] == 0);
            if (cnt == bit[i].count() - 1 && a[i] == 1) forn(j, 1, n) if (bit[i][j] == 1 && b[j] != 0) b[j] = 1;
        }

        forn(i, 1, m) {
            forn(j, 1, n) {
                if (bit[i][j] == 1 && b[j] == 1) a[i] = 1;
            }
        }

        forn(i, 1, m) {
            if (a[i] != -1) continue;
            forn(j, 1, m) {
                if (a[j] != 1) continue;
                if (bit[i].count() == (bit[i] | bit[j]).count()) {
                    a[i] = 1;
                    break;
                }
            }
        }
    }

    forn(i, 1, m) {
        if (a[i] == -1) cout << "?";
        else cout << a[i];
    }
    cout << "\n";

	return 0;
}

Compilation message

ili.cpp: In function 'int main()':
ili.cpp:92:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (cnt == bit[i].count()) a[i] = 0;
                     ^
ili.cpp:98:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (cnt == bit[i].count() - 1 && a[i] == 1) forn(j, 1, n) if (bit[i][j] == 1 && b[j] != 0) b[j] = 1;
                     ^
ili.cpp: At global scope:
ili.cpp:30:23: error: expected unqualified-id before 'for'
 #define forn(x, a, b) for (int x = a; x <= b; ++x)
                       ^
ili.cpp:119:5: note: in expansion of macro 'forn'
     forn(i, 1, m) {
     ^
ili.cpp:119:10: error: 'i' does not name a type
     forn(i, 1, m) {
          ^
ili.cpp:30:39: note: in definition of macro 'forn'
 #define forn(x, a, b) for (int x = a; x <= b; ++x)
                                       ^
ili.cpp:30:47: error: expected unqualified-id before '++' token
 #define forn(x, a, b) for (int x = a; x <= b; ++x)
                                               ^
ili.cpp:119:5: note: in expansion of macro 'forn'
     forn(i, 1, m) {
     ^
ili.cpp:123:5: error: 'cout' does not name a type
     cout << "\n";
     ^
ili.cpp:125:2: error: expected unqualified-id before 'return'
  return 0;
  ^
ili.cpp:126:1: error: expected declaration before '}' token
 }
 ^
ili.cpp: In function 'int main()':
ili.cpp:57:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d\n", &n, &m);
                             ^
ili.cpp:61:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%c", &c);
                        ^
ili.cpp:65:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("\n");
                ^
ili.cpp:69:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%c%d ", &c, &x);
                               ^
ili.cpp:76:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%c%d\n", &c, &x);
                                ^