Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define NMAX 103
- int n, m, top = 1;
- bool a[NMAX][NMAX];
- int inc[NMAX][NMAX], last;
- void read() {
- cin >> n >> m;
- for (int i = 0; i < m; i++) {
- int x, y;
- cin >> x >> y;
- a[x][y] = true;
- }
- }
- void solve() {
- for (int i = 1; i <= n; i++) {
- for (int j = 1; j <= n; j++) {
- if (a[i][j]) {
- last++;
- inc[i][last] = 1;
- inc[j][last] = -1;
- }
- }
- }
- }
- void write() {
- for (int i = 1; i <= n; i++) {
- for (int j = 1; j <= m; j++) {
- cout << inc[i][j] << ' ';
- }
- cout << endl;
- }
- }
- int main() {
- read();
- solve();
- write();
- return 0;
- }
Add Comment
Please, Sign In to add comment